Flask,Gunicorn,NGINX,Docker:configurationSERVER_NAME和proxy_pass的方法是什么?

我使用FlaskgunicornNGINXDocker来设置docker项目,如果我没有在Flask的setting.py文件中添加SERVER_NAME ,这个工作正常。

目前的configuration是:

gunicorn

gunicorn -b 0.0.0.0:5000 

泊坞窗,compose.yml

 services: application: #restart: always build: . expose: - "5000" ports: - "5000:5000" volumes: - .:/code links: - db nginx: restart: always build: ./nginx links: - application expose: - 8080 ports: - "8880:8080" 

NGINX .conf

 server { listen 8080; server_name application; charset utf-8; location / { proxy_pass http://application:5000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } 

然后我在Flask的setting.py中设置了SERVER_NAME

 SERVER_NAME = '0.0.0.0:5000' 

当我向浏览器inputurl 0.0.0.0:8880时 ,我得到了来自nginx的响应404。 Flask的setting.py中应该正确地使用SERVER_NAME

提前致谢。

最后find解决办法,我必须为proxy_set_header指定特定的端口

 proxy_set_header Host $host:5000;