Bug #3005
closedPATH_INFO missing when using uwsgi under scgi
Description
Trying to run a bottle app under lighttpd I found this stumbling block (and a workaround, by patching bottle.py).
I am using lighttpd/1.4.45 (ssl) (Jun 24 2019 22:58:56) and have a site configured as follows
$HTTP["host"] == "mysite.com" {
server.name = "mysite.com"
server.document-root = "/data/www/mysite.com"
scgi.protocol = "uwsgi"
scgi.server = ( "/" => (( "socket" => "/run/uwsgi/app/mysite.com/socket", "check-local" => "disable" )), )
}
and it just returns a 500 error. I traced that to one line in bottle.py that looks for PATH_INFO in the environ and so I checked what's available and it only sees this:
environ is {
'CONTENT_LENGTH': '0',
'QUERY_STRING': '',
'REQUEST_URI': '/',
'REDIRECT_STATUS': '200',
'SCRIPT_NAME': '/',
'SCRIPT_FILENAME': '/data/www/myserver.com/',
'DOCUMENT_ROOT': '/data/www/myserver.com',
'REQUEST_METHOD': 'GET',
'SERVER_PROTOCOL': 'HTTP/1.0',
'SERVER_SOFTWARE': 'lighttpd/1.4.45',
'GATEWAY_INTERFACE': 'CGI/1.1',
'SERVER_PORT': '80',
'SERVER_ADDR': '192.168.0.15',
'SERVER_NAME': 'myserver.com',
'REMOTE_ADDR': '192.168.0.1',
'REMOTE_PORT': '52178',
'HTTP_HOST': 'myserver.com',
'HTTP_CACHE_CONTROL': 'max-age=0',
'HTTP_UPGRADE_INSECURE_REQUESTS': '1',
'HTTP_USER_AGENT': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36',
'HTTP_ACCEPT': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3',
'HTTP_ACCEPT_ENCODING': 'gzip, deflate',
'HTTP_ACCEPT_LANGUAGE': 'en-US,en;q=0.9,eo;q=0.8,de;q=0.7',
'HTTP_X_FORWARDED_FOR': '192.168.0.11',
'HTTP_X_HOST': 'myserver.com',
'HTTP_X_FORWARDED_HOST': 'myserver.com',
'HTTP_X_FORWARDED_PROTO': 'http',
'HTTP_CONNECTION': 'close',
'wsgi.input': < uwsgi._Input object at 0x7f88444e5438 > ,
'wsgi.file_wrapper': < built - in function uwsgi_sendfile > ,
'wsgi.version': (1, 0),
'wsgi.errors': < _io.TextIOWrapper name = 2 mode = 'w'
encoding = 'UTF-8' > ,
'wsgi.run_once': False,
'wsgi.multithread': False,
'wsgi.multiprocess': True,
'wsgi.url_scheme': 'http',
'uwsgi.version': b '2.0.15-debian',
'uwsgi.node': b 'arachne'
}
The patch I put into bottle.py just has a fallback for PATH_INFO of / and works fine for my little app, but doesn't generalise well.
lighttpd should really populate PATH_INFO in this case methinks.
Updated by gstrauss over 4 years ago
- Status changed from New to Invalid
- Target version deleted (
1.4.x)
You are using "check-local" => "disable"
which means "do not check the local filesystem". How do you think PATH_INFO is generated?
Please add "fix-root-scriptname" => "enable"
your scgi.server
definition, and take a look at the documentation.
mod_scgi refers to mod_fastcgi for the description of *.server options.
Updated by bwechner over 4 years ago
Thanks for the triage and feedback. I admit though that the wiki notes on mod_scgi on those options are not very lucid and that I observe this.
If I use "check-local" => "enable"
I simply get a 403 permission denied error.
That puzzles me as I have lighttpd running as:
server.username = "www-data"
server.groupname = "www-data"
and the directory specified as `server.document-root` has UID something else but GID of www-data. So I'm not capiching why lightpd throws a 403 while trying to check-local.
And the wiki lends no clues. And so I use "check-local" => "disable"
and "fix-root-scriptname" => "enable"
as suggested then all works fine. But this wiki documentation `use this for backends with extension "/" (and check-local is disabled) (since 1.4.23)` is meaningless to me and I'd contend an average punter and leaves the puzzling question why this config:
scgi.server = ( "/" => (( "socket" => "/run/uwsgi/app/mysite.com/socket", "check-local" => "disable" )), )
doesn't see the key "/"
passed in as PATH_INFO say? Or that the `fix-root-scriptname` documentation includes some note about providing a PATH_INFO of `/` where PATH_INFO is not provided because check-local is disabled and the backend needs PATH_INFO - for example uwsgi applications`
Also available in: Atom