Docker Nginx已停止:[emerg] 1#1:在上游找不到主机 [英] Docker Nginx stopped: [emerg] 1#1: host not found in upstream

查看:235
本文介绍了Docker Nginx已停止:[emerg] 1#1:在上游找不到主机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在ECS服务器上运行docker-nginx.我的Nginx服务突然停止,因为其中一台服务器的proxy_path无法访问.错误如下:

I am running docker-nginx on ECS server. My nginx service is suddenly stopped because the proxy_path 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.

推荐答案

包含以防止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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆