python - Lors de l'utilisation de Docker + Gunicorn + Nginx dans l'environnement de développement, seule l'interface de bienvenue de Niginx est visible
滿天的星座
滿天的星座 2017-06-16 09:19:02
0
1
984

Utilisez Docker + Gunicorn + Nginx pour exécuter Django dans l'environnement de développement. Une fois le serveur démarré, vous ne pouvez voir que l'interface de bienvenue de Nginx.

Le fichier Docker est le suivant :

django :

FROM python:3.5

ENV PYTHONUNBUFFERED 1

RUN groupadd -r django \
    && useradd -r -g django django

COPY ./requirements.txt /requirements.txt
RUN pip install --no-cache-dir -r /requirements.txt \
    && rm -rf /requirements.txt

COPY ./compose/django/gunicorn.sh /
RUN sed -i 's/\r//' /gunicorn.sh \
    && chmod +x /gunicorn.sh \
    && chown django /gunicorn.sh

COPY . /app

RUN chown -R django /app

RUN mkdir /static
RUN chown -R django /static

USER django

WORKDIR /app

nginx :

FROM nginx:latest
ADD nginx.conf /etc/nginx/sites-enabled/django_blog.conf

gunicorn.sh

#!/bin/sh
python /app/manage.py collectstatic --noinput
/usr/local/bin/gunicorn blogproject.wsgi -w 4 -b 127.0.0.1:8000 --chdir=/app

Configuration 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"

Exécuter la commande :
docker-compose build
docker-compose up

Il semble que Nginx ne transmette pas la demande à Gunicorn ? S'il vous plaît, donnez-moi quelques conseils !

滿天的星座
滿天的星座

répondre à tous(1)
滿天的星座

Veuillez entrer le conteneur nginx pour voir l'emplacement du fichier de configuration

Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!