nginx作为代理多个虚拟主机

运行Windows Server 2008 R2

端口8080上的nginx端口80上的Apache

Apache正在托pipe指令中configuration的5个网站。

我正在尝试将nginxconfiguration为Apache前的代理,(我将在完成testing后反转端口号)。

nginx.conf包含这个服务器,

server { listen 8080; server_name www.domain1.com; root PATH/domain1/; index index.html index.htm index.php; location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ { expires 365d; } ## send request back to apache1 ## location / { proxy_pass http://127.0.0.1; proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504; proxy_redirect off; proxy_buffering off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } }server { listen 8080; server_name www.domain2.com; root PATH/domain2/; index index.html index.htm index.php; ## send request back to apache1 ## location / { proxy_pass http://127.0.0.1; proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504; proxy_redirect off; proxy_buffering off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } 

它的工作原理,但如果我添加第二个服务器,第二个服务器将导致404错误,因为nginx仍在尝试查找站点1文件夹中的第二个站点的内容。

什么是在nginx上configuration多个网站的正确方法? (视窗)。

第一个猜测:你改变configuration后重新启动/重新加载你的nginx?

你configuration看起来确定迄今; 我会包括一个单独的access_log /path/to/domainX_access.log指令到每个服务器{} – 部分更好的debugging; 至less你会从日志中知道哪个虚拟主机被满足了。