兩天的工作,我仍然堅持。我正在運行單獨的nginx和應用程序容器。應用程序容器有一個燒瓶應用程序,在端口8000上運行gunicorn進程。nginx和燒瓶碼頭集裝箱504錯誤
每次我導航到localhost:8080
這是nginx端口80映射到本地主機,我得到一個加載屏幕和一個nginx 504錯誤。
泊塢窗,compose.yml
version: '2'
services:
web:
restart: always
build: ./web_app
expose:
- "8000"
ports:
- "8000:8000"
volumes:
- ./web_app:/data/web
command: /usr/local/bin/gunicorn web_interface:app -w 4 -t 90 --log-level=info -b :8000 --reload
depends_on:
- postgres
nginx:
restart: always
build: ./nginx
ports:
- "8080:80"
volumes_from:
- web
depends_on:
- web
postgres:
restart: always
image: postgres:latest
volumes_from:
- data
volumes:
- ./postgres/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
- ./backups/postgresql:/backup
expose:
- "5432"
data:
restart: always
image: alpine
volumes:
- /var/lib/postgresql
tty: true
nginx.conf
server {
listen 80;
server_name localhost;
charset utf-8;
location /static/ {
alias /data/web/crm/web_interface;
}
location = /favicon.ico {
alias /data/web/crm/web_interface/static/favicon.ico;
}
location/{
proxy_pass http://web:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
nginx的Dockerfile
FROM nginx:latest
RUN rm /etc/nginx/conf.d/default.conf
COPY ./nginx.conf /etc/nginx/conf.d/nginx.conf
我會提供更多的信息,如果需要得到一些關於我在掙扎的這個問題上的幫助。
你能直接在'localhost:8000'上訪問gunicorn服務器嗎? –
不,我嘗試過沒有成功。 –
這是有道理的,我可以訪問它與暴露的端口和映射,但我仍然不能。 –