I have lighttpd version 1.4.73 running on Alpine Linux. I enabled mod_scgi and added this to my configuration file:
scgi.protocol = "uwsgi"
scgi.server = (
"/tp2/" => ( "tp2-app" => (
"host" => "127.0.0.1",
"port" => 8080,
"check-local" => "disable",
"fix-root-scriptname" => "enable",
"fix_root_path_name" => "enable"
)
),
)
My Bottle.py crashes because it can't find PATH_INFO. I reduced the problem to this minuscle pure Python wsgi application that displays the request's environment variables:
def application(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/plain;charset=utf-8')])
page = [f'@Hello World!\n'.encode("utf-8")]
for key, value in environ.items():
page.append(f"{key} = {value}\n".encode("utf-8"))
return sorted(page)
I run this app with:
uwsgi --uwsgi-socket 127.0.0.1:8080 --plugin python3 -w hello_world_app
And indeed, PATH_INFO is not set by lighttpd:
HTTP/1.1 200 OK
Content-Type: text/plain;charset=utf-8
Accept-Ranges: bytes
Content-Length: 943
Date: Sun, 24 Mar 2024 18:22:09 GMT
Server: lighttpd/1.4.73
@Hello World!
CONTENT_LENGTH = 0
DOCUMENT_ROOT = /var/www/localhost/htdocs
GATEWAY_INTERFACE = CGI/1.1
HTTP_ACCEPT = */*
HTTP_HOST = tp2.test
HTTP_USER_AGENT = curl/8.5.0
QUERY_STRING = date=2024-03-24T14:22:10-04:00
REDIRECT_STATUS = 200
REMOTE_ADDR = 192.168.3.10
REMOTE_PORT = 35690
REQUEST_METHOD = GET
REQUEST_SCHEME = http
REQUEST_URI = /tp2/hello?date=2024-03-24T14:22:10-04:00
SCRIPT_FILENAME = /var/www/localhost/htdocs/tp2/hello
SCRIPT_NAME = /tp2/hello
SERVER_ADDR = 192.168.3.30
SERVER_NAME = tp2.test
SERVER_PORT = 80
SERVER_PROTOCOL = HTTP/1.1
SERVER_SOFTWARE = lighttpd/1.4.73
uwsgi.node = b'tp2.test'
uwsgi.version = b'2.0.23'
How can I forward everything under the path /tp2/ to my application and have PATH_INFO available for Bottle?
lighttpd gateway server host options
If
"check-local" => "disable", then lighttpd does not check the URL against the filesystem under the document-root and does not generatePATH_INFO, asPATH_INFOis the part of the url-path after the script name, and lighttpd has been told not to check the local filesystem, and instead to treat the entire url-path in the request asSCRIPT_NAME.PATH_INFO: https://www.rfc-editor.org/rfc/rfc3875.html#section-4.1.5If you are using
"check-local" => "disable"then your script should be looking at the request that was made, notPATH_INFO. e.g.SCRIPT_NAMEandQUERY_STRING, or the non-standardREQUEST_URIprovided by lighttpd, which containsSCRIPT_NAME, optionalPATH_INFO, andQUERY_STRING.Practical answer: if you remove
"check-local" => "disable"from your configuration and you touch an otherwise empty file namedtp2under yourserver.document-root, thenPATH_INFOmight be generated in the way you want.(Alternatively, fix your uwscgi app to not rely on
PATH_INFOand you can keep"check-local" => "disable")"fix-root-scriptname" => "enable"is for when thescgi.serveris handling"/"(root of the path), which does not apply to"/tp2/"so this does not appear to have any effect in your configuration.What is
"fix_root_path_name" => "enable"? Where did you find that or cut-n-paste that? (Hint: it is not valid)