Created
November 18, 2012 16:09
-
-
Save hermansc/4106022 to your computer and use it in GitHub Desktop.
Gunicorn config & ab-test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### /etc/gunicorn.d/ukeweb.gunicorn | |
CONFIG = { | |
'mode': 'wsgi', | |
'environment': { | |
'PYTHONPATH': '/var/www/uka.no/staging/ukeweb/', | |
}, | |
'user': 'uka-web', | |
'group': 'uka-web', | |
'args': ( | |
'--bind=0.0.0.0:5060', | |
'--workers=10', | |
'htdocs.gunicorn:application' | |
), | |
} | |
------------------------------------------------------------------------------ | |
### /var/www/uka.no/staging/ukeweb/htdocs/gunicorn.py | |
import os | |
activation_file = "/var/www/uka.no/www/ukeweb-prod/virtualenv/bin/activate_this.py" | |
execfile(activation_file, dict(__file__=activation_file)) | |
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "ukeweb.settings") | |
from django.core.handlers.wsgi import WSGIHandler | |
application = WSGIHandler() | |
------------------------------------------------------------------------------ | |
### /etc/apache2/site-available/staging.uka.no | |
<VirtualHost staging.uka.no:443> | |
# Server config and logs | |
ServerAdmin [email protected] | |
ServerName staging.uka.no | |
CustomLog /var/log/apache2/access-staging.uka.no.log combined | |
ErrorLog /var/log/apache2/error-staging.uka.no.log | |
DocumentRoot /var/www/uka.no/staging/ukeweb/htdocs | |
# SSL settings | |
SSLEngine On | |
SSLCertificateFile /etc/apache2/ssl/www.uka.no.crt | |
SSLCertificateKeyFile /etc/apache2/ssl/www.uka.no.key | |
SSLCertificateChainFile /etc/apache2/ssl/gd_intermediate.crt | |
# Redirects | |
RewriteEngine On | |
RewriteRule ^(/stats/) /var/www/uka.no/stats/ | |
RewriteRule ^/questionnaire/(.*) https://staging.uka.no/skjema/$1 [R,L] | |
RewriteRule ^/program/gruppesalg(.*) https://staging.uka.no/gruppesalg$1 [R,L] | |
RewriteRule ^/adminmedia/(.*) /var/lib/python-support/python2.5/django/contrib/admin/media/$1 [QSA,L] | |
RewriteRule ^/(media.*) /var/www/uka.no/staging/ukeweb/$1 [QSA,L] | |
# Proxy (other) traffic to gunicorn | |
SetEnv force-proxy-request-1.0 1 | |
ProxyPreserveHost On | |
RewriteRule ^(.*) http://localhost:5060$1 [P] | |
# If url is not favicon.ico, robots.txt or sitemap.xml, use fcgi.script to handle request | |
#RewriteCond %{SCRIPT_FILENAME} !/(favicon.ico|robots.txt|sitemap.xml)$ | |
#RewriteRule ^(.*)$ /staging-ukeweb.fcgi/$1 [QSA,L] | |
# Use itkacl /web/uka/alle for access to innsida and related sites | |
<LocationMatch "^/(login|innsida|media/innsida|admin)"> | |
AuthType Kerberos | |
KrbAuthRealms SAMFUNDET.NO | |
Krb5Keytab /etc/apache2/krb5/www.uka.no.keytab | |
KrbMethodK5Passwd on | |
AuthName "UKA-13 - Cash is king" | |
Require itkacl /web/uka/alle | |
</LocationMatch> | |
# Allow all requests to ical download, due to restrictions from google calendar. | |
<Location /innsida/vaktsys/ical> | |
Allow from all | |
Satisfy any | |
</Location> | |
# Static file settings | |
<Location /> | |
AddOutputFilterByType DEFLATE text/html application/javascript | |
</Location> | |
<Location /media> | |
Options -Indexes | |
ExpiresActive On | |
ExpiresDefault "now plus 2 days" | |
FileETag none | |
AddOutputFilterByType DEFLATE text/css application/x-javascript | |
</Location> | |
<Location /media/files/Info/presse> | |
Options +Indexes | |
</Location> | |
<LocationMatch "^/media/(cache|upload/files)"> | |
Options -Indexes | |
ExpiresActive On | |
ExpiresDefault "now plus 5 years" | |
FileETag none | |
</LocationMatch> | |
<Location /stats> | |
Options -Indexes | |
</Location> | |
</VirtualHost> | |
<VirtualHost staging.uka.no:80> | |
ServerAdmin [email protected] | |
ServerName staging.uka.no | |
CustomLog /var/log/apache2/access-staging.uka.no.log combined | |
ErrorLog /var/log/apache2/error-staging.uka.no.log | |
DocumentRoot /var/www/uka.no/staging/ukeweb/htdocs | |
<Location /innsida/vaktsys/ical> | |
Allow from all | |
Satisfy any | |
</Location> | |
RewriteEngine On | |
# Pass på en noen sider alltid blir kjørt over https | |
# Sjekk om vi faktisk er på SSL eller om vi er bak en ssl terminert | |
# varnish | |
RewriteCond %{HTTPS} !=on | |
RewriteRule ^/(admin|applications|innsida|media/innsida|gruppesalg|questionnaire|skjema|program/billetter)(.*) https://%{SERVER_NAME}/$1$2 [R,L] | |
RewriteRule ^/adminmedia/(.*) /var/lib/python-support/python2.5/django/contrib/admin/media/$1 [QSA,L] | |
RewriteRule ^/(media.*) /var/www/uka.no/staging/ukeweb/$1 [QSA,L] | |
# Proxy (other) traffic to gunicorn | |
SetEnv force-proxy-request-1.0 1 | |
ProxyPreserveHost On | |
RewriteRule ^(.*) http://localhost:5060$1 [P] | |
#RewriteCond %{SCRIPT_FILENAME} !/(favicon.ico|robots.txt|sitemap.xml)$ | |
#RewriteRule ^(.*)$ /staging-ukeweb.fcgi/$1 [QSA,L] | |
<Location /> | |
AddOutputFilterByType DEFLATE text/html application/javascript | |
</Location> | |
<Location /media> | |
Options -Indexes | |
ExpiresActive On | |
ExpiresDefault "now plus 2 days" | |
FileETag none | |
AddOutputFilterByType DEFLATE text/css application/x-javascript | |
</Location> | |
<LocationMatch "^/media/(cache|upload/files)"> | |
Options -Indexes | |
ExpiresActive On | |
ExpiresDefault "now plus 5 years" | |
FileETag none | |
</LocationMatch> | |
</VirtualHost> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment