2017-10-29 12 views
1

私は以下のようなDockerfileを構築しています:なぜ、コンテナ内からuwsgiポートを公開すると、nginxは502 BAD GATEWAYを受け取るのですか?

FROM python:2-jessie 

ENV DOCKER_MODE=1 

EXPOSE 1818 

# everything is copied to my_app like uwsgi.ini and app files 
COPY . /my_app 

WORKDIR /my_app 

CMD ["uwsgi", "--ini", "uwsgi.ini"] 

それは魔法のように動作:私はドッカイメージを実行して33000などのポートを割り当てると

Sun Oct 29 15:17:34 2017 - uWSGI http bound on 127.0.0.1:1818 fd 4 
Sun Oct 29 15:17:34 2017 - uwsgi socket 0 bound to TCP address 127.0.0.1:43183 (port auto-assigned) fd 3 
Sun Oct 29 15:17:34 2017 - Python version: 2.7.14 (default, Oct 10 2017, 02:49:49) [GCC 4.9.2] 
Sun Oct 29 15:17:34 2017 - Python main interpreter initialized at 0x1e347e0 
Sun Oct 29 15:17:34 2017 - python threads support enabled 
Sun Oct 29 15:17:34 2017 - your server socket listen backlog is limited to 100 connections 
Sun Oct 29 15:17:34 2017 - your mercy for graceful operations on workers is 10 seconds 
Sun Oct 29 15:17:34 2017 - mapped 1155328 bytes (1128 KB) for 50 cores 
Sun Oct 29 15:17:35 2017 - WSGI app 0 (mountpoint='') ready in 1 seconds on interpreter 0x1e347e0 pid: 1 (default app) 
Sun Oct 29 15:17:35 2017 - *** uWSGI is running in multiple interpreter mode *** 
Sun Oct 29 15:17:35 2017 - spawned uWSGI master process (pid: 1) 
Sun Oct 29 15:17:35 2017 - spawned uWSGI worker 1 (pid: 9, cores: 50) 
Sun Oct 29 15:17:35 2017 - *** Stats server enabled on 127.0.0.1:11818 fd: 12 *** 
Sun Oct 29 15:17:35 2017 - spawned uWSGI http 1 (pid: 10) 

、そのポートで待機しています:

[email protected]:~/application$ sudo netstat -nltp | grep 33000 
tcp6  0  0 :::33000    :::*     LISTEN  10922/docker-proxy 

何も間違っているようです。今、ポート80で以下のように私のnginxのプロキシパス要求:

proxy_pass http://127.0.0.1:33000; 

は私がポート80に私の要求を送信すると、私は502 Bad Gateway Errorを取得します。なぜそれが起こっているのですか?

答えて

1

UWSGIは127.0.0.1にバインドされました。これをコンテナの0.0.0.0に変更しました。以下のようなものがあります:

http-socket=0.0.0.0:1818 
関連する問題