nginx反向代理修复远程URL

我在nginx反向代理背后的不同机器上有一个wordpress站点。 远程主机是10.0.1.1/kehitys/testi/wordpress,我想将其作为www.host.com/提供。 有没有什么办法可以configurationnginx从URL中删除/ kehitys / testi / wordpress /,并由远程服务器返回?

我的configuration如下所示:

location / { rewrite /(.*) /kehitys/testi/wordpress/$1 break; proxy_pass http://10.0.1.10; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_redirect http://10.0.1.10/kehitys/testi/wordpress/ /; proxy_bind 10.0.1.1; proxy_pass_header Set-Cookie; } 

当然是!

我一直在做同样的事情 – 用nginx做起来要比在stream上configuration第三方软件容易得多!

 location / { proxy_pass http://10.0.1.10/kehitys/testi/wordpress/; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; } location /kehitys/testi/wordpress/ { rewrite ^/kehitys/testi/wordpress/(.*)$ /$1 redirect; }