いくつかのコンテナーがある docker-compose で環境をセットアップしようとしています。
- ジャンゴ
- ニンクス
- ポストグル
- DbData
- 保管所
次の構成を使用しました。
app:
restart: always
build: src
expose:
- "8000"
links:
- postgres:postgres
volumes_from:
- storage_files_1
env_file: .env
command: gunicorn barbell.wsgi:application \
-b 0.0.0.0:8000 -w 4
nginx:
restart: always
build: nginx
ports:
- "80:80"
- "443:443"
volumes_from:
- storage_files_1
links:
- app:app
postgres:
restart: always
image: postgres:latest
volumes_from:
- storage_data_1
ports:
- "5432:5432"
nginx サイト対応の構成ファイルは次のようになります。
server {
listen 80;
server_name localhost;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
location /static {
alias /static/;
autoindex on;
}
location / {
proxy_pass http://app:8000;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Real-IP $remote_addr;
add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"';
}
}
nginx は常に 502 を返しますが、静的ファイルを完全に提供します。uwsgiでも同じセットアップを試しましたが、うまくいきませんでした。ただし、Django と nginx を組み合わせて同じコンテナーからすべてを提供すると、すべてが機能します (これも uwsgi と gunicorn の両方で)。
私は何が欠けているのですか?
アップデート
nginx のログは次のとおりです。
*1 connect() failed (111: Connection refused) while connecting to upstream,
client: 172.17.42.1, server: 0.0.0.0, request: "GET / HTTP/1.1", upstream:
"http://172.17.1.75:8000/", host: "localhost"