Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SSL on Apache2 with WSGI [closed]

Tags:

ssl

apache2

wsgi

I am trying to set up SSL on a Django site I maintain and having a bit of trouble setting up my VirtualHost with SSL. I followed the instructions here but every time I try to restart apache, it tells me it cannot restart because of multiple virtualhosts usign the same wsgi config:

/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! 

I understand what is happening, just not how to fix it. Any suggestions are appreciated, thanks! Here is what my VirutalHosts file looks like:

<VirtualHost *:80>     ServerAdmin [email protected]     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 [email protected]     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> 
like image 753
Shane Reustle Avatar asked Feb 04 '11 00:02

Shane Reustle


2 Answers

Remove the line:

WSGIDaemonProcess mydomain user=myuser group=mygroup processes=1 threads=1 

from the VirtualHost for 443. The WSGIProcessGroup for mydomain in that VirtualHost is able to reach across to the WSGIDaemonProcess definition in 80.

In other words, as the error message tries to suggest, the name for the WSGIDaemonProcess, ie., 'mydomain', must be unique for the whole Apache server.

Referring across VirtualHosts as indicated means both HTTP and HTTPS variants of site will still run in same daemon process group/interpreter.

like image 126
Graham Dumpleton Avatar answered Oct 10 '22 20:10

Graham Dumpleton


Posting in hopes it will help another...

I encountered this error because a virtual host file had been symlinked twice in the sites-enabled directory.

like image 43
user2765486 Avatar answered Oct 10 '22 19:10

user2765486