Docker Nginx 停止:[emerg] 1#1:在上游找不到主机 [英] Docker Nginx stopped: [emerg] 1#1: host not found in upstream
问题描述
我在 ECS 服务器上运行 docker-nginx.我的 nginx 服务突然停止,因为其中一台服务器的 proxy_pass
无法访问.错误如下:
I am running docker-nginx on ECS server. My nginx service is suddenly stopped because the proxy_pass
of one of the servers got unreachable. The error is as follows:
[emerg] 1#1: host not found in upstream "dev-example.io" in /etc/nginx/conf.d/default.conf:988
我的配置文件如下:
server {
listen 80;
server_name test.com;
location / {
proxy_pass http://dev-exapmle.io:5016/;
proxy_redirect 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;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
}
}
server {
listen 80 default_server;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
我的配置文件中有很多台服务器,即使一台服务器宕机了,我也需要运行 nginx.有什么办法可以解决吗?
I have many servers in the config file, even if one server was down, I need to have running nginx. Is there any way to fix it?
如有任何解决此问题的建议,我们将不胜感激.
Any suggestion to fix this issue would be appreciated.
推荐答案
Include 以防止 Nginx 在您的站点关闭时崩溃,包括一个解析器指令,如下所示:
Include to prevent Nginx from crashing if your site is down, include a resolver directive, as follows:
server {
listen 80;
server_name test.com;
location / {
resolver 8.8.8.8;
proxy_pass http://dev-exapmle.io:5016/;
proxy_redirect off;
...
警告!使用公共 DNS 会给您的后端带来安全风险,因为您的 DNS 请求可能会被欺骗.如果这是一个问题,您应该将解析器指向安全的 DNS 服务器.
WARNING! Using a public DNS create a security risk in your backend since your DNS requests can be spoofed. If this is an issue, you should point the resolver to a secure DNS server.
这篇关于Docker Nginx 停止:[emerg] 1#1:在上游找不到主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!