Nginx proxy_pass to another droplet hosting Wordpress troubles with php

November 5, 2015 638 views
PHP Nginx WordPress Ubuntu

Hello,

I recently decided to give Nginx a try on one droplet, but I still need to proxy_pass the path http://tld.com/guides to another Apache droplet hosting wordpress

Here is my proxypass conf:


        location /guides {
                rewrite ^/guides/(.*)$ /$1 break;

                proxy_set_header X-Real-IP  $remote_addr;
                proxy_set_header X-Forwarded-For $remote_addr;
                proxy_set_header Host $host;
                proxy_pass http://droplet_private_ip:80;
                proxy_redirect off;
        }

The this is that Nginx is redirecting all wordpress's php files to the fpm, I think it's due to this

        location ~ \.php$ {
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini

                # With php5-cgi alone:
                #fastcgi_pass 127.0.0.1:9000;
                # With php5-fpm:
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                include fastcgi_params;
        }

Is there a way to exclude all requests from /guides ?

Thanks in advance for your help

1 Answer

I've fixed it. Just in case someone has the same problem. This fixed my problem

        location ~* ^((?!\/guides)(.+)\.php)$ {
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini

                # With php5-cgi alone:
                #fastcgi_pass 127.0.0.1:9000;
                # With php5-fpm:
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                include fastcgi_params;
        }

This part exactly

 location ~* ^((?!\/guides)(.+)\.php)$ {

It makes sure that all .php files from /guides are not handeled by the fpm

Have another answer? Share your knowledge.