Я могу без проблем настроить свой домен для https с помощью следующего файла example.com.conf:
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
DocumentRoot /www/example.com
ErrorLog /var/log/example.com/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/example.com_access.log combined
RewriteEngine on
</VirtualHost>
Затем я запускаю certbot --apache, выбираю свой домен, устанавливаю сертификат и затем выбираю вариант 2: Безопасный - перенаправление всех запросов для безопасного доступа HTTPS. Файл example.com-le-ssl.conf создается следующим образом:
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName example.com
ServerAlias www.example.com
DocumentRoot /www/example.com
ErrorLog /var/log/example.com/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/example.com_access.log combined
RewriteEngine on
SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>
а посещение example.com перенаправляет на https://example.com и иду прямо к https://example.com тоже отлично работает.
Теперь я хотел бы изменить конфигурацию apache для работы с django
Я попытался использовать файл example.com.conf внизу, а затем запустить команду certbot --apache, но она выдает ошибку
Name duplicates previous WSGI daemon definition.
Я также попытался изменить файл после того, как он заработал, как показано выше, но безуспешно. Есть идеи, как это сделать правильно?
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
WSGIPassAuthorization On
WSGIDaemonProcess myapp python-home=/opt/MyProject-Master python-path=/opt/MyProject-Master/MyProject processes=2 threads=5
WSGIProcessGroup myapp
WSGIScriptAlias / /path/MyProject-Master/MyProject/MyProject/wsgi.py process-group=myapp
<Directory /path/MyProject-Master/MyProject/MyProject>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
ErrorLog /var/log/example.coms/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/example.com_access.log combined
</VirtualHost>
запустите команду certbot --apache, пока у вас закомментированы строки WSGI, а затем не комментируйте их после выполнения команды. Надеюсь, это поможет...
#WSGIDaemonProcess myapp python-home=/opt/MyProject-Master python-path=/opt/MyProject-Master/MyProject processes=2 threads=5
#WSGIProcessGroup myapp
#WSGIScriptAlias / /path/MyProject-Master/MyProject/MyProject/wsgi.py process-group=myapp