Opened 8 years ago

Closed 8 years ago

#881 closed defect (invalid)

Nginx with php-fpm + SSI

Reported by: ehsan310@… Owned by:
Priority: major Milestone: 1.9
Component: nginx-module Version: 1.9.x
Keywords: Cc:
uname -a: Linux Device-A37F2B 2.6.32-504.12.2.el6.x86_64 #1 SMP Wed Mar 11 22:03:14 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
nginx -V: nginx version: openresty/1.9.3.1
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-16) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/usr/local/openresty/nginx --with-cc-opt=-O2 --add-module=../ngx_devel_kit-0.2.19 --add-module=../echo-nginx-module-0.58 --add-module=../xss-nginx-module-0.05 --add-module=../ngx_coolkit-0.2rc3 --add-module=../set-misc-nginx-module-0.29 --add-module=../form-input-nginx-module-0.11 --add-module=../encrypted-session-nginx-module-0.04 --add-module=../srcache-nginx-module-0.30 --add-module=../ngx_lua-0.9.16 --add-module=../ngx_lua_upstream-0.03 --add-module=../headers-more-nginx-module-0.26 --add-module=../array-var-nginx-module-0.04 --add-module=../memc-nginx-module-0.16 --add-module=../redis2-nginx-module-0.12 --add-module=../redis-nginx-module-0.3.7 --add-module=../rds-json-nginx-module-0.14 --add-module=../rds-csv-nginx-module-0.06 --with-ld-opt=-Wl,-rpath,/usr/local/openresty/luajit/lib --with-ipv6 --with-pcre-jit --with-http_stub_status_module --with-http_geoip_module --with-http_realip_module --with-http_ssl_module

Description

Hello,

we have a php-fpm configured with nginx fastcgi ,

The problem is we have SSI in our html files which mentiones location which is php-backend ,

When we open that location directly in browser , everythings works fine, but when we use SSI for the same location PATH_INFO is empty so our script doesn't work.

   location /backend { ## URL string to use for api ##
        alias /var/www/html/backend/web/; ## Site root for api code ##

        ## Check for file existing and if there, stop ##
        if (-f $request_filename) {
            break;
        }

        ## Check for file existing and if there, stop ##
        if (-d $request_filename) {
            break;
        }

        ## If we get here then there is no file or directory matching request_filename ##
        rewrite (.*) /backend/index.php?$query_string;

        ## Normal php block for processing ##
        location ~ \.php(?:$|/) {
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $request_filename;
            fastcgi_param PATH_INFO $fastcgi_path_info;
            fastcgi_param HTTP_IPCOUNTRY $geoip_country_code;
            fastcgi_pass php-handler;
            fastcgi_read_timeout 600; # Increase this to allow larger uploads
            access_log off; # Disable logging for performance
        }

    }

Change History (7)

comment:1 by Ilyas Bakirov, 8 years ago

Look for a workaround in ticket:321

comment:2 by Maxim Dounin, 8 years ago

Please provide URI you use (and/or full SSI command you use), how you expect it to be handled, and how it's handled instead.

comment:3 by ehsan310@…, 8 years ago

The URI is , http://IP/backend/site/home
This works fine when i open from browser and i have a expected output.

<!--# include virtual="/backend/site/home" -->

But SSI won't work with same path and i have a error from my backend.PATH_INFO is empty

comment:4 by Maxim Dounin, 8 years ago

Resolution: invalid
Status: newclosed

As per your configuration, the "/backend/site/home" is expected to be either:

  • returned as static file (if appropriate file exists),
  • or redirected to a URI with added "/" (if appropriate directory exists),
  • or rewritten to "backend/index.php?$query_string".

In neither case PATH_INFO will be set.

I'm closing this ticket as it doesn't looks like a bug in nginx. If you have further question on how to configure nginx, please use support options available.

comment:5 by ehsan310@…, 8 years ago

Let's make it more clear,

When i open example.html which have SSI inside , the request which will be sent to our backend side , will only have "/" as a URI,

But when we open "/backend/site/home" directly from browser PATH_INFO and URI will be sent fine.

The problem is i think when we use SSI , the URI request to "/backend/site/home" should be "/" or "site/home" ?

comment:6 by ehsan310@…, 8 years ago

Resolution: invalid
Status: closedreopened

comment:7 by Maxim Dounin, 8 years ago

Resolution: invalid
Status: reopenedclosed

You didn't provide enough information to understand what goes wrong in your configuration and why it happens. As a blind guess - note that when using default fastcgi_params, REQUEST_URI as sent to fastcgi application will be the original URI of main request, not an URI of SSI subrequest (see ticket #288). If you are using it in your scripts and expect it to match subrequest URI, consider using SCRIPT_NAME or DOCUMENT_URI instead.

As previously suggested, if you have further question on how to configure nginx, please use support options available.

Note: See TracTickets for help on using tickets.