python - 開發(fā)環(huán)境下使用 Docker + Gunicorn + Nginx 只能看到 Niginx 歡迎界面
問題描述
在開發(fā)環(huán)境下使用 Docker + Gunicorn + Nginx 來運行 Django,服務器啟動后只能看到 Nginx 歡迎界面。
Dockerfile 如下:
django:
FROM python:3.5ENV PYTHONUNBUFFERED 1RUN groupadd -r django && useradd -r -g django djangoCOPY ./requirements.txt /requirements.txtRUN pip install --no-cache-dir -r /requirements.txt && rm -rf /requirements.txtCOPY ./compose/django/gunicorn.sh /RUN sed -i ’s/r//’ /gunicorn.sh && chmod +x /gunicorn.sh && chown django /gunicorn.shCOPY . /appRUN chown -R django /appRUN mkdir /staticRUN chown -R django /staticUSER djangoWORKDIR /app
nginx:
FROM nginx:latestADD nginx.conf /etc/nginx/sites-enabled/django_blog.conf
gunicorn.sh
#!/bin/shpython /app/manage.py collectstatic --noinput/usr/local/bin/gunicorn blogproject.wsgi -w 4 -b 127.0.0.1:8000 --chdir=/app
nginx.conf 配置:
server { charset utf-8; listen 80 default_server; location /static {alias /app/static; } location / {proxy_pass_header Server;proxy_set_header Host $http_host;proxy_pass http://127.0.0.1:8000; }}
docker-compose.yml
version: ’3’services: django: build: context: . dockerfile: ./compose/django/Dockerfile command: /gunicorn.sh nginx: build: ./compose/nginx depends_on: - django ports: - '80:80'
運行命令:docker-compose builddocker-compose up
似乎是 Nginx 沒有把請求轉發(fā)給 Gunicorn?求指點!
問題解答
回答1:請進入nginx容器看清楚配置文件的位置
相關文章:
1. mysql日期類型默認值’0000-00-00’ 報錯2. 求救一下,用新版的phpstudy,數(shù)據(jù)庫過段時間會消失是什么情況?3. mysql replace 死鎖4. mysql - C#連接數(shù)據(jù)庫時一直這一句出問題int i = cmd.ExecuteNonQuery();5. MYSQL 根據(jù)兩個字段值查詢 但兩個值的位置可能是互換的,這個怎么查?6. extra沒有加載出來7. android - 安卓做前端,PHP做后臺服務器 有什么需要注意的?8. javascript - 微信網(wǎng)頁開發(fā)從菜單進入頁面后,按返回鍵沒有關閉瀏覽器而是刷新當前頁面,求解決?9. php傳對應的id值為什么傳不了啊有木有大神會的看我下方截圖10. mysql - ubuntu開啟3306端口失敗,有什么辦法可以解決?
