2017-10-29 10 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; 

I 포트 80 내 요청을 보낼

, 나는 502 Bad Gateway Error를 얻을. 왜 그런 일이 일어나는거야?

답변

1

UWSGI가 127.0.0.1으로 바뀌 었으므로 컨테이너의 0.0.0.0으로 변경했습니다. 다음과 같은 것을 가지고 있습니다 :

http-socket=0.0.0.0:1818