带有WSGI的Apache2上的SSL

时间:2011-02-04 00:41:33

标签: ssl apache2 wsgi

我正在尝试在我维护的Django网站上设置SSL,并且在使用SSL设置我的VirtualHost时遇到一些麻烦。我按照here的说明进行操作,但每次尝试重新启动apache时,都会告诉我由于多个虚拟主机使用相同的wsgi配置而无法重启:

/etc/init.d/apache2 reload
Syntax error on line 33 of /etc/apache2/sites-enabled/www.mydomain.com:
Name duplicates previous WSGI daemon definition.
...fail!

我明白发生了什么,而不是如何解决它。任何建议表示赞赏,谢谢!这是我的VirutalHosts文件的样子:

<VirtualHost *:80>
    ServerAdmin my@email.com
    ServerName mydomain.com
    ServerAlias www.mydomain.com
    DocumentRoot /sites/mydomain

    # WSGI Settings
    WSGIScriptAlias / /sites/mydomain/wsgi_handler.py
    WSGIDaemonProcess mydomain user=myuser group=mygroup processes=1 threads=1
    WSGIProcessGroup mydomain

    # Static Directories
    Alias /static /sites/mydomain/static/
    <Location "/static">
            SetHandler None
    </Location>

    Alias /img /sites/mydomain/img/
    <Location "/img">
            SetHandler None
    </Location>

</VirtualHost>

<VirtualHost *:443>
    ServerAdmin my@email.com
    ServerName mydomain.com
    ServerAlias www.mydomain.com
    DocumentRoot /sites/mydomain

    # WSGI Settings
    WSGIScriptAlias / /sites/mydomain/wsgi_handler.py
    WSGIDaemonProcess mydomain user=myuser group=mygroup processes=1 threads=1
    WSGIProcessGroup mydomain

    # Static Directories
    Alias /static /sites/mydomain/static/
    <Location "/static">
            SetHandler None
    </Location>

    Alias /img /sites/mydomain/img/
    <Location "/img">
            SetHandler None
    </Location>

    # SSL Stuff
    SSLEngine On
    SSLCertificateFile /etc/apache2/ssl/crt/vhost1.crt
    SSLCertificateKeyFile /etc/apache2/ssl/key/vhost1.key
    <Location />
            SSLRequireSSL On
            SSLVerifyClient optional
            SSLVerifyDepth 1
            SSLOptions +StdEnvVars +StrictRequire
    </Location>
</VirtualHost>

2 个答案:

答案 0 :(得分:48)

删除该行:

WSGIDaemonProcess mydomain user=myuser group=mygroup processes=1 threads=1
来自VirtualHost for 443的

。该VirtualHost中mydomain的WSGIProcessGroup能够在80中达到WSGIDaemonProcess定义。

换句话说,正如错误消息试图建议的那样,WSGIDaemonProcess的名称,即“mydomain”,对于整个Apache服务器必须是唯一的。

如所指示的那样引用VirtualHosts意味着站点的HTTP和HTTPS变体仍将在同一个守护进程组/解释器中运行。

答案 1 :(得分:12)

希望它会帮助另一个......

我遇到此错误,因为虚拟主机文件已在启用站点的目录中进行了两次符号链接。