在Ubuntu服务器上使用SSL和子域进行Flask设置

问题描述

我是Flask的新手,正在尝试在子域https://ohl.bhelpful.net上设置Flask网页。我在https://bhelpful.net上运行了另一个与此烧瓶应用程序无关的网页。

当我输入“ service apache2 reload” 并尝试继续进行https://ohl.bhelpful.net时,它只是给我以下信息:

Error when trying to view webpage

https://bhelpful.net上的主要网站(仅是纯HTML格式)如下:

Image of main website working

我的配置文件如下:

/etc/apache2/sites-available/default-ssl.conf

Listen 443
<IfModule mod_ssl.c>

        <VirtualHost *:443>

                ServerAdmin webmaster@localhost

                DocumentRoot "/home/bhelpful/html"
                ServerName bhelpful.net
                ServerAlias www.bhelpful.net

                SSLEngine on
                SSLCertificateFile "/etc/ssl/bhelpful_net.crt"
                SSLCertificateKeyFile "/etc/ssl/private/bhelpful_net.key"

        </VirtualHost>

        <VirtualHost *:443>

                ServerAdmin webmaster@localhost
                ServerName ohl.bhelpful.net
                WsgiScriptAlias / /home/ohl/ohl.wsgi
                <Directory /home/ohl/Online-Help-List/app/>
                        Order allow,deny
                        Allow from all
                </Directory>

                Alias /static /home/ohl/Online-Help-List/app/static/
                <Directory /home/ohl/Online-Help-List/app/static/>
                        Order allow,deny
                        Allow from all
                </Directory>

                ErrorLog ${APACHE_LOG_DIR}/FlaskApp-error.log
                LogLevel warn
                CustomLog ${APACHE_LOG_DIR}/FlaskApp-access.log combined

                SSLEngine on
                SSLCertificateFile "/etc/ssl/bhelpful_net.crt"
                SSLCertificateKeyFile "/etc/ssl/private/bhelpful_net.key"

        </VirtualHost>

</IfModule>

# vim: Syntax=apache ts=4 sw=4 sts=4 sr noet

Wsgi文件如下:

/home/ohl/ohl.wsgi

#!/usr/bin/python3
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/home/ohl/Online-Help-List")

from app.help_me import app as application

主烧瓶文件位于此处: / home / ohl /在线帮助列表/app/help_me.py

Treeview of files and folders

解决方法

使用这些命令

授予权限

chmod 755 / home / ohl /在线帮助列表/ app /

修改

/etc/apache2/sites-available/default-ssl.conf

替换

允许订单,拒绝
全部允许

注意:这是针对Apache 2.2

替换为

AllowOverride全部
要求所有授予

注意:这适用于Apache 2.4 +