我有一个nginx服务器充当我的apache服务器的负载平衡器。 我正在使用子域,我的代码依赖于HTTP_HOST值来执行正确的任务。
当我发出请求说: http://get.example.com : http://get.example.com一旦它被转发Apache的HTTP_HOST成为example.com 。
我的问题是如何使它保持原来的要求相同?
这是我的nginxconfiguration:
upstream example.com { server 192.168.2.1:8909 weight=2; server 192.168.2.2:8909 weight=1; server 192.168.2.3:8909 weight=1; } server { listen 80; location / { proxy_pass http://example.com; } }
我试图添加多个proxy_pass ,每个子域的一个,它似乎并没有工作。
您需要传递HTTP Host头。 将此添加到相关location :
proxy_set_header Host $host;