我有一个TurboGears(v2.2.1或v2.3.1)网站在Apache下运行在HTTP上。 HTTP网站工作正常,但我试图将其移动到HTTPS并且正在撞墙。我有两个.conf文件,并尝试将配置块从正在运行的HTTP配置复制到HTTPS配置。
Apache设置如下:
/etc/apache2/sites-enabled/000-default.conf -> /etc/sites-available/000-default.conf
/etc/apache2/sites-enabled/default-ssl.conf -> /etc/sites-available/default-ssl.conf
我在网站上使用HTTP的配置是:
/etc/apache2/sites-available/000-default.conf:
WSGIPythonHome /usr/local/pythonenv/BASELINE
WSGIPythonPath /usr/local/pythonenv/myapp/lib/python2.7/site-packages
<VirtualHost *:80>
ServerAdmin webmaster@mydomain.com
ServerName myhost.mydomain.com
DocumentRoot /var/www
<Directory />
...
</Directory>
<Directory /var/www/>
...
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
...
</Directory>
# Start website configuration
Alias /myapp/img /usr/local/turbogears/myapp/myapp/public/img
Alias /myapp/css /usr/local/turbogears/myapp/myapp/public/css
Alias /myapp/javascript /usr/local/turbogears/myapp/myapp/public/javascript
WSGIDaemonProcess myapp threads=10 processes=3
WSGIProcessGroup myapp
WSGIScriptAlias /myapp /usr/local/turbogears/myapp/apache/myapp.wsgi
# Directory Permissions.
<Directory /usr/local/turbogears/myapp/apache>
Order deny,allow
allow from ...
deny from all
</Directory>
# End website configuration
... #more entries for Trac and Doxygen websites
</VirtualHost>
/etc/apache2/sites-available/default-ssl.conf:
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin webmaster@localhost
SSLEngine On
DocumentRoot /var/www/ssl
# THIS IS WHERE I TRY CUT/PASTING THE CONFIGURATION BLOCK FROM THE HTTP WEBSITE
<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
</VirtualHost>
</IfModule>
ports.conf:
Listen 80
<IfModule mod_ssl.c>
Listen 443
</IfModule>
<IfModule mod_gnutls.c>
Listen 443
</IfModule>
SSLCertificateFile /admin/webcerts/mycert.cer
SSLCertificateKeyFile /admin/webcerts/myprivate.key
在apache2.conf中:
...
Include mods-enabled/*.load
Include mods-enabled/*.conf
Include ports.conf
Include sites-enabled/
Include /etc/phpmyadmin/apache.conf
LoadModule passenger_module /var/lib/gems/1.9.1/gems/passenger-4.0.5/libout/apache2/mod_passenger.so
PassengerRoot /var/lib/gems/1.9.1/gems/passenger-4.0.5
PassengerDefaultRuby /usr/bin/ruby1.9.1
...
要在HTTPS上部署网站,我将网站配置块从000-default.conf移动到default-ssl.conf并重启apache但是我收到404错误:
Not Found
The requested URL /myapp was not found on this server.
我已经尝试将全局WSGIPythonHome和WSGIPythonPath指令移动到default-ssl.conf中,以防首先读取该文件(它应该不是我所知道的那样),但这没有帮助。日志文件不包含我可以看到的任何有用信息。
我有很少的Apache经验,但是从其他SO线程来看,似乎有些东西在Ubuntu 13中发生了变化。例如,default-ssl.conf中的DocumentRoot指令对我来说不起作用,这可能很重要。在/etc/apache2/apache2.conf中为DocumentRoot添加全局值确实有效,但问题在于它是全局的。
端口443上的404页面将这些列为Apache已加载的模块:
Apache/2.4.6 (Ubuntu)
PHP/5.5.3-1ubuntu2
mod_python/3.3.1
Python/2.7.5+
OpenSSL/1.0.1e
mod_wsgi/3.4
Phusion_Passenger/4.0.5
在我还有一些头发的时候,任何帮助都会受到赞赏!
答案 0 :(得分:0)
对我来说(烦人的)解决方案是改变
<VirtualHost *:443>
到
<VirtualHost _default_:443>
这起初有效,但后来失败了。似乎是什么
<VirtualHost servers.main.ip.address:443>
一个因素可能是服务器有四个网络接口。
要获得此解决方案,我首先注意到/ var / log / apache2中的SSL访问日志为空,表明SSL站点甚至没有被提供。然后我尝试在127.0.0.1上运行SSL站点并在本地进行测试工作 - 它确实抱怨了SSL证书,因为它是使用DNS条目创建的。一些更多的搜索引导我到上面的解决方案。如果这不是一个好的解决方案,请告诉我,但它似乎对我来说很好。