Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash for unknown reason #27

Open
ethernidee opened this issue Jan 31, 2023 · 1 comment
Open

Crash for unknown reason #27

ethernidee opened this issue Jan 31, 2023 · 1 comment

Comments

@ethernidee
Copy link

The following simple .htaccess file produces 500 error:

## No directory listings
Options -Indexes

<IfModule autoindex>
  IndexIgnore *
</IfModule>

RewriteEngine On
RewriteBase /

## Begin - Rewrite rules to block out some common exploits ##
RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
RewriteRule .* index.php [F]
## End - Rewrite rules to block out some common exploits ##

# Remove trailing backslash from URIs
RewriteCond %{REQUEST_METHOD} =GET
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)\/$ $1 [R=301,L]

## Begin - Core SEF Section ##
#RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_URI} !^/index\.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [L]
## End - Core SEF Section ##

Error:

*211 lua entry thread aborted: runtime error: /etc/nginx/lua/htaccess.lua:796: bad argument #2 to 'gsub' (string/function/table expected)
stack traceback:
coroutine 0:
  [C]: in function 'gsub'
  /etc/nginx/lua/htaccess.lua:796: in function 'replace_server_vars'
  /etc/nginx/lua/htaccess.lua:1060: in function </etc/nginx/lua/htaccess.lua:1>, client: 0.0.0.0, server: test.com, request: "POST /api/receive-signals HTTP/1.1", host: "test.com"
2023/01/31 04:30:31 [error] 766145#766145: *212 lua entry thread aborted: runtime error: /etc/nginx/lua/htaccess.lua:796: bad argument #2 to 'gsub' (string/function/table expected)
stack traceback:
coroutine 0:
  [C]: in function 'gsub'
  /etc/nginx/lua/htaccess.lua:796: in function 'replace_server_vars'
  /etc/nginx/lua/htaccess.lua:1060: in function </etc/nginx/lua/htaccess.lua:1>, client: 0.0.0.0, server: test.com, request: "GET /admin/panel HTTP/2.0", host: "test.com", referrer: "https://test.com/admin/login"
2023/01/31 04:30:33 [error] 766145#766145: *212 lua entry thread aborted: runtime error: /etc/nginx/lua/htaccess.lua:796: bad argument #2 to 'gsub' (string/function/table expected)
stack traceback:
coroutine 0:
  [C]: in function 'gsub'
  /etc/nginx/lua/htaccess.lua:796: in function 'replace_server_vars'
  /etc/nginx/lua/htaccess.lua:1060: in function </etc/nginx/lua/htaccess.lua:1>, client: 0.0.0.0, server: test.com, request: "GET /favicon.ico HTTP/2.0", host: "test.com", referrer: "https://test.com/admin/panel"
rkaiser0324 added a commit to rkaiser0324/htaccess-for-nginx that referenced this issue Jan 31, 2023
@ethernidee
Copy link
Author

I would also look at the following code:

elseif svar == 'script_filename' then -- %{SCRIPT_FILENAME}
  replace = ngx.var['fastcgi_script_name']
  
  if not replace or replace == '' then
    replace = ngx.var['request_filename']
  else
    replace = (ngx.var['document_root']..'/'..script_filename):gsub('/+', '/')
  end
  replace = script_filename

Seems like the last line replace = script_filename is odd or condition block should be removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant