我有一个 Nginx Web 服务器作为代理服务器。它代理两个不同的 Web 服务器,一个是 IIS,另一个是 GitLab 服务器。第一个虚拟地址工作正常,但第二个虚拟地址不工作。我已将我的配置包含在下面。此配置以前可以正常工作。我已将服务器从一台服务器移至另一台服务器。唯一改变的是服务器的内部 IP 地址。服务器本身工作正常。
server {
server_name vcontrol.mysite.uk;
location /.well-known {
alias /var/www/defaultcertbot/.well-known;
}
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://172.168.0.32;
}
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/vcontrol.mysite.uk/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/vcontrol.mysite.uk/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = vcontrol.mysite.uk) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
listen [::]:80;
server_name vcontrol.mysite.uk;
return 404; # managed by Certbot
}
server {
server_name mysite.uk www.mysite.uk;
location /.well-known {
alias /var/www/defaultcertbot/.well-known;
}
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://172.168.0.33;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/mysite.uk/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/mysite.uk/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = mysite.uk) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = www.mysite.uk) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
server_name mysite.uk www.mysite.uk;
return 404; # managed by Certbot
}
172.168.0.33 是 IIS 服务器,也是未解析站点的服务器。站点上的绑定正确,URL 解析到正确的 IP 地址。检查 IIS 服务器。我已将 vcontrol 内部 IP 更改为 33,它确实显示了 IIS 站点。配置问题一定出在默认站点配置中。
任何帮助都将不胜感激
答案1
配置没问题。问题出在路由器上,我输入的 IP 地址不正确。