[horde] migrate fastcgi_split_path_info to uwsgi
Grouchy Sysadmin
sysadmin at grouchysysadmin.com
Sun Dec 23 23:42:47 UTC 2018
On 12/23/18 8:21 AM, A. Schulze wrote:
> cross-posting to horde & nginx lists...
>
> Hello,
>
> I plan to migrate a PHP Application (horde) from php-fpm to uwsgi.
> nginx talk "fastcgi protocol" to php-fpm now and have to talk "uwsgi protocol" to uwsgi later.
>
> Horde uses partially arguments as URL elements.
> example comment in https://github.com/horde/base/blob/master/services/ajax.php
>
> the corresponding nginx config I currently use:
>
> location ~ /horde/services/ajax.php/ {
> fastcgi_split_path_info ^(.+\.php)(/.+)$;
> fastcgi_pass unix:/var/run/php.sock;
> include /etc/nginx/fastcgi.conf;
> }
>
> the example URL used in ajax.php: http://example.com/horde/services/ajax.php/APP/ACTION[?OPTIONS]
>
> without fastcgi_split_path_info:
> SCRIPT_FILENAME /horde/services/ajax.php/APP/ACTION
> PATH_INFO is empty?
>
> with fastcgi_split_path_info:
> SCRIPT_FILENAME /horde/services/ajax.php
> PATH_INFO /APP/ACTION[?OPTIONS]
>
> hope, this is correct so far...
> to verify my setup I configured
>
> location /horde/services/ajax.php {
> fastcgi_split_path_info ^(/horde/services/ajax\.php)(.+)$;
> return 200 "REQUEST_URI: $request_uri, SCRIPT_FILENAME: $fastcgi_script_name, PATH_INFO: $fastcgi_path_info ARGS: $args\n";
> }
>
> $ curl 'https://example.org/horde/services/ajax.php/APP/ACTION?OPTION=foobar'
> REQUEST_URI: /horde/services/ajax.php/APP/ACTION?OPTION=foobar, SCRIPT_FILENAME: /horde/services/ajax.php, PATH_INFO: /APP/ACTION ARGS: OPTION=foobar
>
> that _looks_ correct to me.
>
> Anyway, horde don't work, I get 404 back:
> [pid: 1301|app: -1|req: -1/10] 2001:db8::2 () {58 vars in 1220 bytes} [Sun Dec 23 14:19:22 2018] POST /horde/services/ajax.php/imp/dynamicInit => generated 9 bytes in 0 msecs (HTTP/2.0 404) 2 headers in 71 bytes (0 switches on core 0)
>
>
> Unfortunately there is no "uwsgi_split_path_info" in nginx.
> That means to me
> - it's simply not implemented
> - the problem is solved in a other way.
>
> I appreciate any hint on how to solve the "split" or at least debug what's going on.
>
> Andreas
>
>
>
Hello,
I'm not sure about the 'ajax.php' file, as I've never needed to do
anything special for it. Here's a basic configuration that works for me.
# Handle /
location / {
try_files $uri $uri/ /rampage.php?$args;
}
# Handle /rpc
location /rpc/ {
rewrite ^(.*)$ /rpc/index.php/$1;
}
# Caldav and Carddav rewrites
location ~* /.well-known/(cal|card)dav {
rewrite ^ /rpc/ permanent;
}
# Set expires headers for static content
location ~*
.(jpg|jpeg|png|gif|ico|css|js|ico|gz|bz2|tbz|tgz|svg|svgz|mp4|ogg|ogv|webm|zip|rar|tar|txt|pl)$
{
expires 30d;
}
# PHP files
location ~ [^/]\.php(/|$) {
# Set the uwsgi modifier to PHP
uwsgi_modifier1 14;
include /path/to/uwsgi_parms;
# Pass to UWSGI
uwsgi_pass unix://$socket;
}
That configuration should work assuming you're not using the uWSGI
chroot capability. If you are doing chrooting, let me know and I'll send
a more complete configuration.
More information about the horde
mailing list