如何使用nginx反向代理主页/ root?

时间:2016-08-16 19:28:04

标签: nginx proxy

我有兴趣将访问我网站的根目录/主页的人员发送到其他服务器。

如果他们去其他地方(/ news或/ contact或/hi.html或其他几十个页面中的任何一个),他们会被代理到另一台服务器。

自" /"是nginx catchall将任何未定义的内容发送到特定服务器,并且因为" /"也代表了主页,你可以看到我的困境。

本质上,root / homepage是自己的服务器。其他所有东西都在不同的服务器上。

思想?

1 个答案:

答案 0 :(得分:1)

location =/ {
    # only "/" requests
}

location / {
    # everything else
}

更多信息:http://nginx.org/en/docs/http/ngx_http_core_module.html#location