我有两台服务器在后台运行,我想让nginx反向代理这两台服务器。
我希望nginx在端口80上运行。当用户导航到http://localhost:80/时,他应该被转发到http://localhost:3501。然而,我仍然在http://localhost:80上看到了默认的nginx页面。我在我的本地主机上安装了nginx,并在同一个机器上进行测试。
server {
listen 80;
server_name _;
location ^~/api/* {
proxy_pass http://localhost:8000;
}
location ^~/* {
proxy_pass http://localhost:3501;
}
} 发布于 2013-01-09 15:45:28
upstream backend-testserver {
server 127.0.0.1:3501 weight=1 max_fails=2 fail_timeout=30s; # server 1
server 127.0.0.1:3502 weight=1 max_fails=2 fail_timeout=30s; # server 2
}
location / {
root html;
index index.html index.htm;
proxy_pass http://backend-testserver;
}
https://stackoverflow.com/questions/14230197
复制相似问题