【问题标题】:Kubernetes build django + uwsgi + nginx show failed (111: Connection refused) while connecting to upstreamKubernetes 构建 django + uwsgi + nginx 显示失败(111:连接被拒绝)同时连接到上游
【发布时间】:2020-01-04 21:56:56
【问题描述】:

当我创建 my.yaml 时,nginx 在连接上游时会显示失败(111:连接被拒绝)

对此有什么建议吗?是否有pod网络不连接?

uwsgi:

[uwsgi]
module          = myapp.wsgi
master          = true
processes       = 10
socket          = 127.0.0.1:8001
chmod-socket = 777
vacuum          = true
enable-threads = True

nginx:

upstream django_api {
server 127.0.0.1:8001 max_fails=20 fail_timeout=10s;
}
server {
    listen 80;

    #location /media  {
    #    alias /media;  # your Django project's media files - amend as required
    #}
    location /static {
    alias /usr/share/apps/static; # your Django project's static files - amend as required
    }
    location / {
    uwsgi_read_timeout 60;
    uwsgi_pass  django_api;
    include     ./uwsgi_params; # the uwsgi_params file you installed
    uwsgi_param Host $host;
    uwsgi_param X-Real-IP $remote_addr;
    uwsgi_param X-Forwarded-For $proxy_add_x_forwarded_for;
    uwsgi_param X-Forwarded-Proto $http_x_forwarded_proto;
    }

}

【问题讨论】:

    标签: django nginx kubernetes uwsgi


    【解决方案1】:

    所以只是一个想法,也许将您的 uwsgi 设置为 0.0.0.0:8001 然后在您的 podSpec 上将容器端口值设置为 8001:

    apiVersion: v1
    kind: Pod
    metadata:
      name: mypod
      labels:
        component: web
    spec:
      containers: 
        - name: django
          image: myimage
          ports:
            - containerPort: 8001
        - name: nginx
          image: nginx:alpine
          ....
    
    

    这应该使它在 localhost:8001/127.0.0.1:8001 中可用

    【讨论】:

      【解决方案2】:

      我有类似的设置,将 uwsgi 设置 (uwsgi.ini) 中的 socket=server_name:8081 更改为 socket=:8081 解决了我的问题,请参阅 uWSGI nginx error : connect() failed (111: Connection refused) while connecting to upstream

      【讨论】:

        猜你喜欢
        • 2014-02-26
        • 2012-11-21
        • 2017-10-18
        • 1970-01-01
        • 2020-03-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-11-03
        相关资源
        最近更新 更多