Skip to content

Instantly share code, notes, and snippets.

@turtlemonvh
Created July 1, 2014 03:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save turtlemonvh/aaa47bf00c7d1c1dcd67 to your computer and use it in GitHub Desktop.
Save turtlemonvh/aaa47bf00c7d1c1dcd67 to your computer and use it in GitHub Desktop.
Apache conf for multiple djangos at different ports, with the main version served over https
WSGISocketPrefix /var/run/wsgi
WSGIDaemonProcess site-1 user=myapp group=myapp threads=20
WSGIDaemonProcess site-alt user=myapp group=myapp threads=5
LoadModule ssl_module modules/mod_ssl.so
# Get apache listening on another port
# The "Listen 80" directive is in httpd.conf
Listen 8080
AddType application/vnd.openxmlformats-officedocument.wordprocessingml.document .docx
AddType application/vnd.openxmlformats-officedocument.presentationml.presentation .pptx
AddType application/vnd.openxmlformats-officedocument.spreadsheetml.sheet .xlsx
AddType image/svg+xml svg svgz
AddEncoding gzip svgz
<VirtualHost *:80>
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</VirtualHost>
<VirtualHost *:8080>
ServerName myapp.com
ErrorLog logs/myapp_alt-error.log
CustomLog logs/myapp_alt-access.log common
WSGIApplicationGroup %{GLOBAL}
WSGIScriptAlias / /var/myapp_alt/app-conf/wsgi/app.wsgi
WSGIProcessGroup site-alt
# Added these lines so that the server will know where the media is located
Alias /static_assets/ /var/myapp_alt/app/static_assets/
Alias /static/ /var/myapp_alt/app/static/
<FilesMatch "\.(js|css|png|jpg|gif|svg|swf)$">
# Never Cache SWFs, usually, almost all static files in dev
FileETag None
<IfModule mod_headers.c>
Header unset ETag
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires "Fri, 01 Jan 1990 00:00:00 GMT"
</IfModule>
</FilesMatch>
<Directory /var/myapp_alt/app/static_assets>
#this setting is really not necessary when in production
EnableSendfile Off
Order deny,allow
Allow from all
</Directory>
<Directory /var/myapp_alt/app/static>
#this setting is really not necessary when in production
EnableSendfile Off
Order deny,allow
Allow from all
</Directory>
<Directory /var/myapp_alt/app-conf/wsgi>
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:443>
SSLEngine on
SSLCertificateFile /etc/pki/tls/certs/ca.crt
SSLCertificateKeyFile /etc/pki/tls/private/ca.key
ServerName myapp.com
#ServerPath /
ErrorLog logs/myapp-error.log
CustomLog logs/myapp-access.log common
WSGIApplicationGroup %{GLOBAL}
WSGIScriptAlias / /var/myapp/app-conf/wsgi/app.wsgi
WSGIProcessGroup site-1
# Added these lines so that the server will know where the media is located
Alias /static_assets/ /var/myapp/app/static_assets/
Alias /static/ /var/myapp/app/static/
<FilesMatch "\.(js|css|png|jpg|gif|svg|swf)$">
# Never Cache SWFs, usually, almost all static files in dev
FileETag None
<IfModule mod_headers.c>
Header unset ETag
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires "Fri, 01 Jan 1990 00:00:00 GMT"
</IfModule>
</FilesMatch>
<Directory /var/myapp/app/static_assets>
#this setting is really not necessary when in production
EnableSendfile Off
Order deny,allow
Allow from all
</Directory>
<Directory /var/myapp/app/static>
#this setting is really not necessary when in production
EnableSendfile Off
Order deny,allow
Allow from all
</Directory>
<Directory /var/myapp/app-conf/wsgi>
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment