Skip to content

Instantly share code, notes, and snippets.

@apolloclark
Created January 29, 2015 22:53
Show Gist options
  • Select an option

  • Save apolloclark/3f0e52c527dc169fa982 to your computer and use it in GitHub Desktop.

Select an option

Save apolloclark/3f0e52c527dc169fa982 to your computer and use it in GitHub Desktop.
<VirtualHost *>
WSGIApplicationGroup %{GLOBAL}
# Setup Python for the App1
WSGIDaemonProcess app1 user=www-data group=www-data threads=5
WSGIScriptAlias /app1 /var/www/app1/app1.wsgi
<Directory /var/www/app1>
Order deny,allow
Allow from all
</Directory>
<Location /app1>
WSGIProcessGroup app1
</Location>
# Setup Python for the App2
WSGIDaemonProcess app2 user=www-data group=www-data threads=5
WSGIScriptAlias /app2 /var/www/app2/app2.wsgi
<Directory /var/www/app2>
Order deny,allow
Allow from all
</Directory>
<Location /app2>
WSGIProcessGroup app2
</Location>
</VirtualHost>
@GrahamDumpleton
Copy link
Copy Markdown

If wanting to do both HTTP and HTTPS you should be using the following.

<VirtualHost *:80>

        ServerName mysite.dns.name

        WSGIApplicationGroup %{GLOBAL}

        # Setup Python for the App1

        WSGIDaemonProcess app1 threads=5

        WSGIScriptAlias /app1 /var/www/app1/app1.wsgi

        <Directory /var/www/app1>
                WSGIProcessGroup app1
                Order deny,allow
                Allow from all
        </Directory>

        # Setup Python for the App2

        WSGIDaemonProcess app2 threads=5

        WSGIScriptAlias /app2 /var/www/app2/app2.wsgi

        <Directory /var/www/app2>
                WSGIProcessGroup app2
                Order deny,allow
                Allow from all
        </Directory>

</VirtualHost>

<VirtualHost *:443>

        ServerName mysite.dns.name

        # Add directives here to set up SSL certificate.

        SSLEngine On
        SSLCertificateFile mysite.crt
        SSLCertificateKeyFile mysite.key

        WSGIApplicationGroup %{GLOBAL}

        # Setup Python for the App1. Don't need WSGIDaemonProcess here.
        # Will match against 'app1' defined in *:80 VirtualHost. The *:80
        # VirtualHost must come before that for *:443 for that to work.

        WSGIScriptAlias /app1 /var/www/app1/app1.wsgi

        <Directory /var/www/app1>
                WSGIProcessGroup app1
                Order deny,allow
                Allow from all
        </Directory>

        # Setup Python for the App2. Don't need WSGIDaemonProcess here.
        # Will match against 'app2' defined in *:80 VirtualHost. The *:80
        # VirtualHost must come before that for *:443 for that to work.

        WSGIScriptAlias /app2 /var/www/app2/app2.wsgi

        <Directory /var/www/app2>
                WSGIProcessGroup app2
                Order deny,allow
                Allow from all
        </Directory>

</VirtualHost>

Have also cleaned some things up to remove unnecessary bits or use better ways.

The daemon process groups are set up in *:80 and referred to from *:443. This is so not create distinct processes for HTTP and HTTPS versions of sites.

@GrahamDumpleton
Copy link
Copy Markdown

If HTTPS only and no other requirement for VirtualHosts, then maybe do away with VirtualHost.

        Listen 443

        ServerName mysite.dns.name

        # Add directives here to set up SSL certificate.

        SSLEngine On
        SSLCertificateFile mysite.crt
        SSLCertificateKeyFile mysite.key

        WSGIApplicationGroup %{GLOBAL}

        # Setup Python for the App1.

        WSGIDaemonProcess app1 threads=5

        WSGIScriptAlias /app1 /var/www/app1/app1.wsgi

        <Directory /var/www/app1>
                WSGIProcessGroup app1
                Order deny,allow
                Allow from all
        </Directory>

        # Setup Python for the App2.

        WSGIDaemonProcess app2 threads=5

        WSGIScriptAlias /app2 /var/www/app2/app2.wsgi

        <Directory /var/www/app2>
                WSGIProcessGroup app2
                Order deny,allow
                Allow from all
        </Directory>

@apolloclark
Copy link
Copy Markdown
Author

No, I need SSL enabled, it is required. I cannot change the port configuration, nor add a new domain, nor add a new sub-domain. It needs to be on a shared hosting machine, per a client's security requirements. I've create a new Issue topic on the Google Groups for mod_wsgi. I'll add another comment when the issue is publicly viewable, approved, etc.

@apolloclark
Copy link
Copy Markdown
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment