nginx 错误意味着什么:在 /etc/nginx/sites-enabled/mywebsite.conf 中的上游“my.domain.com”中找不到主机

nginx 错误意味着什么:在 /etc/nginx/sites-enabled/mywebsite.conf 中的上游“my.domain.com”中找不到主机

在 Debian 升级后,之前有效的配置停止工作。我看到的错误systemctl status nginx.servicehost not found in upstream "sync.mydomain.net"

Nov 20 01:05:40 mydomain.net systemd[1]: Starting A high performance web server and a reverse proxy server...
Nov 20 01:05:45 mydomain.net nginx[442]: nginx: [emerg] host not found in upstream "sync.mydomain.net" in /etc/nginx/sites-enabled/myconfig.conf:9
Nov 20 01:05:46 mydomain.net nginx[442]: nginx: configuration file /etc/nginx/nginx.conf test failed
Nov 20 01:05:46 mydomain.net systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE
Nov 20 01:05:46 mydomain.net systemd[1]: nginx.service: Failed with result 'exit-code'.
Nov 20 01:05:46 mydomain.net systemd[1]: Failed to start A high performance web server and a reverse proxy server.

相关配置文件如下所示:

server {
    include myhttpsconfig.conf;
    server_name sync.mydomain.net;
    ssl_certificate     /var/lib/dehydrated/certs/sync.mydomain.net/fullchain.pem;
    ssl_certificate_key /var/lib/dehydrated/certs/sync.mydomain.net/privkey.pem;

    location / {
        include myhttpssubdomain.conf;
        proxy_pass http://sync.mydomain.net:8383;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

}

失败的原因可能是什么?

答案1

我必须承认,我并不完全理解错误到底是什么,但是添加空的第二个参数来server_name明确修复我的配置:

server_name sync.mydomain.net "";

如果您打算使用此解决方案,请务必检查Host服务器收到的 HTTP 标头。这是一个非常不完整的答案,不要依赖于此来确保安全,请自行检查

相关内容