如何设置Nginx将单个文件夹反向代理到一个服务器,将其余的root代理反向代理到另一个服务器?
根“/”由CMS管理,而“其他”是我自己的程序(独立于CMS).
这是我目前的配置
server {
listen 80;
server_name www.example.com;
rewrite ^ https://$server_name$request_uri? permanent;
}
server {
listen 443;
... <ssl stuff> ...
server_name www.example.com;
location /other {
proxy_pass http://192.168.2.2/other ;
}
location / {
proxy_pass http://192.168.1.1;
}
}
解决方法:
对Nginx文档的引用:
http://wiki.nginx.org/HttpCoreModule#location
http://wiki.nginx.org/HttpProxyModule#proxy_pass
您应该将其他位置更改为:
location /other/ {
proxy_pass http://192.168.2.2/other/ ;
}
请注意尾随/.它实际上有所不同,因为它获取proxy_pass来规范化请求.我引用:
when a request is passed to the server, the part of a normalized request URI matching the location is replaced by a URI specified in the [proxy_pass] directive.
这应该有助于找到这个页面的人.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。