我正在努力将Flask应用程序部署到现有的VirtualHost配置中。我想将所有Web应用程序保留在同一个域的同一个域中。当遵循大多数教程时,它没有问题:
<IfModule mod_ssl.c>
<VirtualHost *:81>
<IfModule mod_headers.c>
Header always set Strict-Transport-Security "max-age=15768000; includeSubDomains; preload"
</IfModule>
SSLProxyEngine On
ServerName localhost
WSGIScriptAlias /flasktest /var/www/SetImageText/SetImageText.wsgi
<Directory /var/www/SetImageText/SetImageText/>
Order allow,deny
Allow from all
</Directory>
Alias /static /var/www/SetImageText/SetImageText/static
<Directory /var/www/SetImageText/SetImageText/static/>
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/own_domain/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/own_domain/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/own_domain/fullchain.pem
但是当我尝试将其集成到现有配置中时:
<IfModule mod_ssl.c>
<VirtualHost own_domain:443>
<IfModule mod_headers.c>
Header always set Strict-Transport-Security "max-age=15768000; includeSubDomains; preload"
</IfModule>
SSLProxyEngine On
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<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
# MSIE 7 and newer should be able to use keepalive
BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
DocumentRoot /var/www
<Directory /var/www>
Order allow,deny
deny from all
</Directory>
WSGIScriptAlias /flasktest /var/www/SetImageText/SetImageText.wsgi
<Directory /var/www/SetImageText/SetImageText/>
Order allow,deny
Allow from all
</Directory>
Alias /static /var/www/SetImageText/SetImageText/static
<Directory /var/www/SetImageText/SetImageText/static/>
Order allow,deny
Allow from all
</Directory>
<Directory /var/www/owncloud>
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride None
Order allow,deny
allow from all
Header always set Strict-Transport-Security "max-age=15768000; includeSubDomains; preload"
</Directory>
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/own_domain/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/own_domain/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/own_domain/fullchain.pem
它只会回复404.是否有人知道将这些wsgi内容集成到现有虚拟主机中的可能性?
答案 0 :(得分:0)
我的虚拟主机文件没有您的那么复杂,但是我可以通过遵循mod_wsgi文档中的示例来使我的Flask应用程序正常工作(将WSGIScriptAlias集成到我现有的虚拟主机文件中)。
http://modwsgi.readthedocs.io/en/develop/user-guides/quick-configuration-guide.html
特别是“安装WSGI应用程序”一节中的示例虚拟主机配置。
<VirtualHost *:80>
ServerName www.example.com
ServerAlias example.com
ServerAdmin webmaster@example.com
DocumentRoot /usr/local/www/documents
<Directory /usr/local/www/documents>
Order allow,deny
Allow from all
</Directory>
WSGIScriptAlias /myapp /usr/local/www/wsgi-scripts/myapp.wsgi
<Directory /usr/local/www/wsgi-scripts>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>