python - 開發(fā)環(huán)境下使用 Docker + Gunicorn + Nginx 只能看到 Niginx 歡迎界面
問題描述
在開發(fā)環(huán)境下使用 Docker + Gunicorn + Nginx 來運(yùn)行 Django,服務(wù)器啟動(dòng)后只能看到 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'
運(yùn)行命令:docker-compose builddocker-compose up
似乎是 Nginx 沒有把請(qǐng)求轉(zhuǎn)發(fā)給 Gunicorn?求指點(diǎn)!
問題解答
回答1:請(qǐng)進(jìn)入nginx容器看清楚配置文件的位置
相關(guān)文章:
1. mysql - 分庫(kù)分表、分區(qū)、讀寫分離 這些都是用在什么場(chǎng)景下 ,會(huì)帶來哪些效率或者其他方面的好處2. javascript - ios返回不執(zhí)行js怎么解決?3. python - 爬蟲模擬登錄后,爬取csdn后臺(tái)文章列表遇到的問題4. 視頻文件不能播放,怎么辦?5. python bottle跑起來以后,定時(shí)執(zhí)行的任務(wù)為什么每次都重復(fù)(多)執(zhí)行一次?6. html5 - HTML代碼中的文字亂碼是怎么回事?7. javascript - 求幫助 , ATOM不顯示界面!!!!8. mysql 查詢身份證號(hào)字段值有效的數(shù)據(jù)9. javascript - angular使從elastichearch中取出的文本高亮顯示,如圖所示10. javascript - 為什么在谷歌控制臺(tái) 輸出1的時(shí)候,輸出的1立馬就不見了
