0

我有一个 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>

端口.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

当我还有一些头发时,任何帮助将不胜感激!

4

1 回答 1

0

对我来说(烦人的)解决方案是改变

<VirtualHost *:443>

<VirtualHost _default_:443>

这起初有效,但后来失败了。似乎是什么

<VirtualHost servers.main.ip.address:443>

一个因素可能是服务器有四个网络接口。

为了得到这个解决方案,我首先注意到 /var/log/apache2 中的 SSL 访问日志是空的,这表明 SSL 站点甚至没有被提供服务。然后我尝试在 127.0.0.1 上运行 SSL 站点并在本地测试哪个有效 - 它确实抱怨 SSL 证书,因为它是使用 DNS 条目创建的。更多的搜索使我找到了上面的解决方案。如果这不是一个好的解决方案,请告诉我,但它似乎对我来说很好。

于 2014-01-06T22:18:01.480 回答