Django 프로젝트를 사용하여 HTTPS를 사용하는 경우 표시되는 Apache 기본 페이지

Django 프로젝트를 사용하여 HTTPS를 사용하는 경우 표시되는 Apache 기본 페이지

나는 지난 1주 동안 이 기능을 작동시키려고 노력했지만 전혀 작동하지 않는 것 같습니다. 도와주세요. 여기에 default-ssl 및 001-default에 대한 파일이 있습니다. 웹사이트는 http에서는 제대로 작동하지만 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

답변1

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

Python WSGI 구현을 위한 Apache 모듈인 mod-wsgi를 설치해야 합니다.

사이트 및 필수 모드 활성화

a2enmod ssl rewrite headers wsgi alias

아파치 서비스를 다시 시작하세요

관련 정보