Php Nginx proxy_传递到另一个承载WordPress的服务器

Php Nginx proxy_传递到另一个承载WordPress的服务器,php,wordpress,nginx,Php,Wordpress,Nginx,我最近决定在一个droplet上试用Nginx,但我仍然需要将路径传递给另一个承载wordpress的Apache droplet 这是我的proxypass配置: 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

我最近决定在一个droplet上试用Nginx,但我仍然需要将路径传递给另一个承载wordpress的Apache droplet

这是我的proxypass配置:

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;
}
这是Nginx将所有wordpress的php文件重定向到fpm,我认为这是由于这个原因

  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;
  }

有没有办法排除本地fpm执行来自/guides的所有请求?

我已经解决了这个问题。以防有人有同样的问题。这解决了我的问题

    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;
    }
这部分完全正确

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

它确保/guides中的所有.php文件都不会被fpm处理

我已经修复了它。以防有人有同样的问题。这解决了我的问题

    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;
    }
这部分完全正确

location ~* ^((?!\/guides)(.+)\.php)$ {
它确保fpm不会处理来自/guides的所有.php文件