Django Wagtail return HTTP 500 Внутренняя ошибка сервера - PullRequest
1 голос
/ 03 апреля 2019

Я развертываю свое приложение Wagtail в производство, но не могу заставить его работать. Я следую этому уроку https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-18-04.

Сайт работает на моем сервере, как и ожидалось, при использовании параметров разработки, как только я перешел на работу, он не будет работать.

На работе я могу получить доступ только к URL администратора и карты сайта.

production.py


from .base import *


with open('/etc/secret_key.txt') as f:
    SECRET_KEY = f.read().strip()

DEBUG = False

try:
    from .local import *
except ImportError:
    pass


DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'name',
        'USER': 'user',
        'PASSWORD': 'password',
        'HOST': 'localhost',
        'PORT': '',
    }
}
# SECURITY WARNING: define the correct hosts in production!

INTERNAL_IPS = ("127.0.0.1")
ALLOWED_HOSTS = ['*'] 

Nginx

# Redirect unencrypted traffic to the encrypted site
server {
    listen       80;
    server_name  domain www.domain IP;
    return       301 https://domain$request_uri;
}

server {
    client_max_body_size 20M;
    listen 443 default ssl;
    server_name domain.com IP;
    keepalive_timeout   70;

    ssl on;

    ssl_certificate /etc/nginx/certs.pem;
    ssl_certificate_key /etc/nginx/privkey.pem;

    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
        root /home/user/projectdir;
    }

    location / {
        include proxy_params;
        proxy_pass http://unix:/run/gunicorn.sock;
    }
}

Gunicorn.service

[Unit]
Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target

[Service]
User=sherpa
Group=www-data
WorkingDirectory=/home/user/projectdir
ExecStart=/home/user/projectenv/bin/gunicorn \
          --access-logfile - \
          --workers 3 \
          --bind unix:/run/gunicorn.sock \
          project.wsgi_production:application

[Install]
WantedBy=multi-user.target

urls.py

urlpatterns = [
    url(r'^django-admin/', admin.site.urls),

    url(r'^admin/', include(wagtailadmin_urls)),
    url(r'^documents/', include(wagtaildocs_urls)),

    url(r'^search/$', search_views.search, name='search'),


    url(r'^sitemap.xml', sitemap),
    # For anything not caught by a more specific rule above, hand over to
    # Wagtail's page serving mechanism. This should be the last pattern in
    # the list:
    url(r'', include(wagtail_urls)),


    # Alternatively, if you want Wagtail pages to be served from a subpath
    # of your site, rather than the site root:
    #    url(r'^pages/', include(wagtail_urls)),


]

1 Ответ

0 голосов
/ 15 мая 2019

У меня та же проблема. Если я установил Debug = True, все работает нормально. Если я установлю Debug = False, я получу страницу с ошибкой 500, но в логах ничего не говорится о том, что произошла ошибка. Я использую Apache, а не nginx.

...