我得到了以下配置:
upstream backend {
server xx.azurewebsites.net;
server xxx.azurewebsites.net;
}
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
server_name_;
location / {
proxy_pass http://backend;
}
}
问题是请求总是返回错误 404 页面:https://i.gyazo.com/cb0b81014aac8ea979ad77b246c79377.png
通过浏览器访问 xx.azurewebsites.net 或 xxx.azurewebsites.net 可以,但通过负载均衡器则不行。除了 azurewebsites.net 之外,我还尝试过其他网站,它们也显示 4040 页面。
有人知道我在这里遗漏了什么吗?
nginx.conf:
user Azureuser; // I changed the user from www-user to Azureuser, did't help though
worker_processes auto;
pid /run/nginx.pid;
events {
worker_connections 768;
}
http {
sendfile on;
tcp_nopush on;
tcp:nodelay on;
keepalive_timeout 65;
types_hash_max_size 2448;
include /etc/nginx/mime.tyoes;
default_type application/octet-stream;
gzip on;
gzip_sidable "msie6";
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
负载均衡器:vm-lb-nginx.northeurope.cloudapp.azure.com
服务器 1:spd1.azurewebsites.net
服务器 2:spd2.azurewebsites.net
答案1
Ensure your can visit real server through 80 port.please have a try.
If ok, you should check your dns about the domainName.
upstream webservers {
server xx.azurewebsites.netIP;
server xxx.azurewebsites.netIP;
}
server {
listen 80;
server_name localhost;
location / {
index index.html index.htm;
proxy_pass http://webservers;
proxy_set_header X-Real-IP $remote_addr;
}