Closed dgreco3917 closed 1 year ago
Hi,
I am attempting to move a Zend Framework 1.x app from litespeed over to unit with nginx in front. Having an issue with Zend not finding the controller, seemingly because the URL is of the form "http://foo.com/dave/controller/action/parameters".
Zend is seeing a Request URI of /dave/controller/action/parameters and a SCRIPT_NAME of index.php. In litespeed,
OK.
the URI was the same but the SCRIPT_NAME was dave/index.php. Zend takes the path of the SCRIPT_NAME
OK.
and substracts it from the front of the Request URI to obtain the "controller". Therefore in Unit, Zend is
Hmm, a little confused here.
If SCRIPT_NAME is dave/index.php
and that's removed from the beginning of the request URL then would that not make the request URL dave/index.phpcontroller/action/parameters
?, I could see it being dave/index.php/controller/action/parameters
which Unit does support (when not using the script option).
Zend Framework is removing the path portion of the SCRIPT_NAME from the beginning of the request URL. So a request url of dave/controller/action/parameters with a script_name of /dave/index.php results in "controller/action/parameters" which it then parses to determine which Controller class and Action class to use.
In Unit the SCRIPT_NAME is just "/index.php" so Zend parses this into "dave/controller/action/parameters", which results in it looking for a controller named dave.
OK, so what happens if you put index.php under dave/
?
E.g
{
"listeners": {
"[::1]:8080": {
"pass": "applications/php"
}
},
"applications": {
"php": {
"type": "php",
"root": "/home/andrew/src/php",
"script": "dave/index.php"
}
}
}
$ curl http://localhost:8080/dave/controller/action/parameters
Array
(
[SERVER_SOFTWARE] => Unit/1.32.0
[SERVER_PROTOCOL] => HTTP/1.1
[PHP_SELF] => /dave/index.php
[SCRIPT_NAME] => /dave/index.php
[SCRIPT_FILENAME] => /home/andrew/src/php/dave/index.php
[DOCUMENT_ROOT] => /home/andrew/src/php
[REQUEST_METHOD] => GET
[REQUEST_URI] => /dave/controller/action/parameters
[QUERY_STRING] =>
[REMOTE_ADDR] => ::1
[SERVER_ADDR] => ::1
[SERVER_NAME] => localhost
[SERVER_PORT] => 80
[HTTP_HOST] => localhost:8080
[HTTP_USER_AGENT] => curl/8.0.1
[HTTP_ACCEPT] => */*
[REQUEST_TIME_FLOAT] => 1695412740.8583
[REQUEST_TIME] => 1695412740
)
That does solve the controller location problem. Causes some other problems within the framework, but I think I can work those out- mostly file location differences caused by the difference in the working directory now being dave/
Thanks!
I am attempting to move a Zend Framework 1.x app from litespeed over to unit with nginx in front. Having an issue with Zend not finding the controller, seemingly because the URL is of the form "http://foo.com/dave/controller/action/parameters".
Zend is seeing a Request URI of /dave/controller/action/parameters and a SCRIPT_NAME of index.php. In litespeed, the URI was the same but the SCRIPT_NAME was dave/index.php. Zend takes the path of the SCRIPT_NAME and substracts it from the front of the Request URI to obtain the "controller". Therefore in Unit, Zend is complaining that controller "dave" does not exist.
My unit route: [ { "action": { "share": "/var/git/dev/main/platform/phplib/app/hpp/public$uri", "fallback": { "pass": "applications/hpp" } } } ]
Unit application: { "type": "php 8", "processes": 30, "group": "nobody", "user": "nobody", "stdout": "/var/log/www/hpp.out", "stderr": "/var/log/www/hpp.err", "root": "/var/git/dev/main/platform/phplib/app/hpp/public", "script": "index.php" }
Note that there are static images/js/css files in public that should be served directly.
This looks somewhat similar to a previous issue - https://github.com/nginx/unit/issues/916, though I am not sure if that patch was ever applied or if there was an actual resolution.
Any ideas?