Apache2 Ubuntu 20.4 WSGI无法使SSL正常工作 也许是问题所在?

问题描述

问题

我正在使用Django 3创建一个网站,目前正在设置SSL。该网站在http上运行良好,但是当我尝试使用“让我们加密”制作证书并更改一些设置(因为我使用Wsgi运行Django)时,我在http上获得了认的Apache网站,并出现了一个错误:ERR_SSL_PROTOCOL_ERROR。在https上。

也许是问题所在?

可能的问题是该网站是具有子域的地址,例如:dashboard.websitename.com。但是我对此很确定。

设置

我主要按照此视频进行设置:https://www.youtube.com/watch?v=NhidVhNHfeU

配置

这是我的/etc/apache2/sites-available/000-default.conf。这应该重定向到https页面

<VirtualHost *:80>
    ServerName dashboard.websitename.com
    ServerAlias *.websitename.com

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

    RewriteEngine on
    RewriteCond %{SERVER_NAME} =dashboard.soilspect.nl
    RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

下面是我的/etc/apache2/sites-available/000-default-le-ssl.conf配置。就像我提到的ealier一样,当我仅使用端口80时,我的Wsgi设置都可以正常工作。

<IfModule mod_ssl.c>
  <VirtualHost *:443>        
    ServerName dashboard.websitename.com
    ServerAlias *.websitename.com
    
    DocumentRoot /home/user/project

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

    Alias /static /home/user/project/static
    <Directory /home/user/project/static>
            Require all granted
    </Directory>


    <Directory /home/user/project/app>
            <Files wsgi.py>
                    Require all granted
            </Files>
    </Directory>

    WsgiScriptAlias / /home/user/project/app/wsgi.py
    WsgiDaemonProcess django_app python-path=/home/user/project python-home=/home/user/project/env
    WsgiProcessGroup django_app

    Include /etc/letsencrypt/options-ssl-apache.conf
    SSLCertificateFile /etc/letsencrypt/live/dashboard.websitename.com/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/dashboard.websitename.com/privkey.pem
 </VirtualHost>
</IfModule>

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)