Apache-Standardseite wird angezeigt, wenn HTTPS ein Django-Projekt verwendet

Apache-Standardseite wird angezeigt, wenn HTTPS ein Django-Projekt verwendet

Ich habe in der letzten Woche versucht, dies zum Laufen zu bringen, aber es scheint einfach nicht zu funktionieren. Bitte helfen Sie, hier sind die Dateien für das Standard-SSL und das 001-Standard, die Website funktioniert einwandfrei über http, aber nicht über https. -

<IfModule mod_ssl.c>
<VirtualHost *:443>
    ServerAdmin [email protected]
    ServerName essayeshop.com
    ServerAlias www.essayeshop.com
    DocumentRoot /var/www/html

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    SSLEngine on

    SSLCertificateFile /etc/apache2/ssl/apache.crt
    SSLCertificateKeyFile /etc/apache2/ssl/apache.key

    <FilesMatch "\.(cgi|shtml|phtml|php)$">
            SSLOptions +StdEnvVars
    </FilesMatch>
    <Directory /usr/lib/cgi-bin>
            SSLOptions +StdEnvVars
    </Directory>

    BrowserMatch "MSIE [2-6]" \
            nokeepalive ssl-unclean-shutdown \
            downgrade-1.0 force-response-1.0
</VirtualHost>

ServerName essayeshop.com
ServerAdmin [email protected]
DocumentRoot /var/www/html
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined


Alias /static /home/nick/website/static
<Directory /home/nick/website/static>
    Require all granted
</Directory>

<Directory /home/nick/website/website>
    <Files wsgi.py>
        Require all granted
    </Files>
</Directory>

WSGIDaemonProcess website python-path=/home/nick/website python-home=/home/nick/website/env
WSGIProcessGroup website
WSGIScriptAlias / /home/nick/website/website/wsgi.py
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf

Antwort1

<IfModule mod_ssl.c>
<VirtualHost *:443>
  ServerName  essayeshop.com
  ServerAlias www.essayeshop.com
  DocumentRoot  /var/www/html

  WSGIDaemonProcess essayeshop.com \
    python-home=/path/to/.virtualenv/mysite/ \
    python-path=/path/to/mysite/

  WSGIScriptAlias / /path/to/mysite/wsgi.py \
   process-group=mysite.com \
   application-group=%{GLOBAL}

  <Directory /path/to/mysite>
    <Files wsgi.py>
      Require all granted
    </Files>
  </Directory>

  <Directory /path/to/.virtualenvs/mysite>
    Require all granted
  </Directory>

  <Directory /path/to/mysite/logs>
    Require all granted
  </Directory>

  Alias /media/ /path/to/mysite/media/
  Alias /static/ /path/to/mysite/static/

  ErrorLog /var/log/apache2/mysite-error.log
  LogLevel warn
  CustomLog /var/log/apache2/mysite-access.log combined

  SSLEngine on
  SSLCertificateFile /path/to/cert/cert.pem
  SSLCertificateKeyFile /path/to/cert/privkey.pem
</VirtualHost>
</IfModule>

Wir müssen mod-wsgi installieren, ein Apache-Modul zur Implementierung von Python WSGI.

Site und erforderliche Mods aktivieren

a2enmod ssl rewrite headers wsgi alias

und starten Sie die Apache-Dienste neu

verwandte Informationen