PageRenderTime 123ms CodeModel.GetById 80ms app.highlight 3ms RepoModel.GetById 38ms app.codeStats 0ms

/silverlining/server-root/etc/apache2/sites-enabled/wsgi_runner

https://bitbucket.org/ianb/silverlining/
#! | 175 lines | 148 code | 27 blank | 0 comment | 0 complexity | 9f30d3952e3bdb93632f8e873e03d386 MD5 | raw file
  1RewriteLock /var/lock/apache2/rewrite.lck
  2
  3<VirtualHost 127.0.0.1:8080>
  4	ServerAdmin webmaster@localhost
  5
  6	#DocumentRoot /var/www
  7	<Directory />
  8		Options FollowSymLinks
  9		AllowOverride None
 10	</Directory>
 11	<Directory /var/www/>
 12		Options Indexes FollowSymLinks MultiViews
 13		AllowOverride None
 14		Order allow,deny
 15		allow from all
 16	</Directory>
 17
 18	#ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
 19	#<Directory "/usr/lib/cgi-bin">
 20	#	AllowOverride None
 21	#	Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
 22	#	Order allow,deny
 23	#	Allow from all
 24	#</Directory>
 25
 26	<LocationMatch />
 27         # Insert filter
 28        SetOutputFilter DEFLATE
 29
 30        # Netscape 4.x has some problems...
 31        BrowserMatch ^Mozilla/4 gzip-only-text/html
 32
 33        # Netscape 4.06-4.08 have some more problems
 34        BrowserMatch ^Mozilla/4\.0[678] no-gzip
 35
 36        # MSIE masquerades as Netscape, but it is fine
 37        BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
 38        # Don't compress images
 39        SetEnvIfNoCase Request_URI \
 40        \.(?:gif|jpe?g|png)$ no-gzip dont-vary
 41
 42        # Make sure proxies don't deliver the wrong content
 43        Header append Vary User-Agent env=!dont-vary
 44    </LocationMatch>
 45
 46	ErrorLog /var/log/apache2/error.log
 47
 48	# Possible values include: debug, info, notice, warn, error, crit,
 49	# alert, emerg.
 50	LogLevel warn
 51
 52        ## FIXME: %l and %u are always -; why bother?
 53        # 10.5.2.1 - - [Date] "GET /foo HTTP/1.1" 200 9430 "http://ref" "Mozilla/blah" thisserver.com "some_app" 103000
 54        LogFormat "%{SILVER_FORWARDED}e %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\" %{HTTP_HOST}e \"%{SILVER_APP_NAME}e\" %D" wsgi_combined
 55	CustomLog /var/log/apache2/access.log wsgi_combined
 56
 57## Python/WSGI setup:
 58RewriteEngine on
 59## Uncomment if you want to understand what is happening here:
 60#RewriteLog /var/log/apache2/rewrite.log
 61#RewriteLogLevel 5
 62
 63# Strip www. from all (non-https) domains:
 64RewriteCond %{SERVER_PORT} ^8080$
 65RewriteCond %{HTTP_HOST} ^www\.(.*)$
 66RewriteRule (.*) http://%1$1 [L,R=permanent]
 67
 68RewriteCond %{HTTP_HOST} ^(.*)(:8080)?$
 69RewriteRule . - [E=SILVER_REDIR_HOST:http://%1]
 70
 71RewriteCond %{HTTP:X-Forwarded-For} ^([0-9.]+)
 72RewriteRule . - [E=SILVER_FORWARDED:%1]
 73
 74RewriteMap appdata prg:/usr/local/share/silverlining/mgr-scripts/rewrite-map.py
 75RewriteCond ${appdata:%{HTTP_HOST}^%{REQUEST_URI}} (.*)
 76RewriteRule . - [E=SILVER_APP_DATA:%1]
 77# Special case redirect:
 78RewriteCond %{ENV:SILVER_APP_DATA} ^addslash$
 79RewriteRule (.*) %{ENV:SILVER_REDIR_HOST}$1/ [L,R=permanent]
 80RewriteCond %{ENV:SILVER_APP_DATA} ^error:(.*)$
 81RewriteRule . /usr/local/share/silverlining/error/routing-error.html [R=500,L,E=ERROR_MSG:%1]
 82RewriteCond %{ENV:SILVER_APP_DATA} (.*)\|(.*)\|(.*)\|(.*)\|(.*)\|(.*)\|(.*)
 83RewriteRule . - [E=SILVER_MATCH_PATH:%1]
 84RewriteCond %{ENV:SILVER_APP_DATA} (.*)\|(.*)\|(.*)\|(.*)\|(.*)\|(.*)\|(.*)
 85RewriteRule . - [E=SILVER_INSTANCE_NAME:%2]
 86RewriteCond %{ENV:SILVER_APP_DATA} (.*)\|(.*)\|(.*)\|(.*)\|(.*)\|(.*)\|(.*)
 87RewriteRule . - [E=SILVER_PROCESS_GROUP:%3]
 88RewriteCond %{ENV:SILVER_APP_DATA} (.*)\|(.*)\|(.*)\|(.*)\|(.*)\|(.*)\|(.*)
 89RewriteRule . - [E=CONFIG_WRITABLE_ROOT:%4]
 90RewriteCond %{ENV:SILVER_APP_DATA} (.*)\|(.*)\|(.*)\|(.*)\|(.*)\|(.*)\|(.*)
 91RewriteRule . - [E=SILVER_PLATFORM:%5]
 92RewriteCond %{ENV:SILVER_APP_DATA} (.*)\|(.*)\|(.*)\|(.*)\|(.*)\|(.*)\|(.*)
 93RewriteRule . - [E=SILVER_PHP_ROOT:%6]
 94RewriteCond %{ENV:SILVER_APP_DATA} (.*)\|(.*)\|(.*)\|(.*)\|(.*)\|(.*)\|(.*)
 95RewriteRule . - [E=SILVER_REMAINING_URI:%7]
 96
 97RewriteCond %{ENV:SILVER_INSTANCE_NAME} ^([^.]*)\.
 98RewriteRule . - [E=SILVER_APP_NAME:%1]
 99
100RewriteCond %{HTTP_HOST} ^(.*)(?:\:\d+)?$
101RewriteRule . - [E=SILVER_HOST:%1]
102
103# Refuse /index.html files (redirect):
104RewriteCond /var/www/%{ENV:SILVER_INSTANCE_NAME}/static%{ENV:SILVER_REMAINING_URI} -f
105RewriteRule (.*/)index.html %{ENV:SILVER_REDIR_HOST}$1 [L,R=permanent]
106# Serve up any static files:
107RewriteCond /var/www/%{ENV:SILVER_INSTANCE_NAME}/static%{ENV:SILVER_REMAINING_URI} -f
108RewriteRule . /var/www/%{ENV:SILVER_INSTANCE_NAME}/static%{ENV:SILVER_REMAINING_URI} [L]
109# Add a trailing slash when necessary:
110RewriteCond /var/www/%{ENV:SILVER_INSTANCE_NAME}/static%{ENV:SILVER_REMAINING_URI} -d
111RewriteCond %{ENV:SILVER_REMAINING_URI} [^/]$
112RewriteCond /var/www/%{ENV:SILVER_INSTANCE_NAME}/static%{ENV:SILVER_REMAINING_URI}/index.html -f
113RewriteRule (.*) %{ENV:SILVER_REDIR_HOST}$1/ [L,R=permanent]
114# Otherwise serve up index.html:
115RewriteCond /var/www/%{ENV:SILVER_INSTANCE_NAME}/static%{ENV:SILVER_REMAINING_URI}/index.html -f
116RewriteRule . /var/www/%{ENV:SILVER_INSTANCE_NAME}/static%{ENV:SILVER_REMAINING_URI}/index.html [L]
117
118## FIXME: even when there is no writable root, these all get run:
119## Repeat static serving for writable-root files; this entire stanza
120## is repeated twice, first using the host-specific location, then a
121## more general location:
122
123## Per-host:
124# Refuse /index.html files (redirect):
125RewriteCond %{ENV:CONFIG_WRITABLE_ROOT}/%{ENV:SILVER_HOST}%{ENV:SILVER_REMAINING_URI} -f
126RewriteRule (.*/)index.html %{ENV:SILVER_REDIR_HOST}$1 [L,R=permanent]
127# Serve up any static files:
128RewriteCond %{ENV:CONFIG_WRITABLE_ROOT}/%{ENV:SILVER_HOST}%{ENV:SILVER_REMAINING_URI} -f
129RewriteRule . %{ENV:CONFIG_WRITABLE_ROOT}/%{ENV:SILVER_HOST}%{ENV:SILVER_REMAINING_URI} [L]
130# Add a trailing slash when necessary:
131RewriteCond %{ENV:CONFIG_WRITABLE_ROOT}/%{ENV:SILVER_HOST}%{ENV:SILVER_REMAINING_URI} -d
132RewriteCond %{ENV:SILVER_REMAINING_URI} [^/]$
133RewriteCond %{ENV:CONFIG_WRITABLE_ROOT}/%{ENV:SILVER_HOST}%{ENV:SILVER_REMAINING_URI}/index.html -f
134RewriteRule (.*) %{ENV:SILVER_REDIR_HOST}$1/ [L,R=permanent]
135# Otherwise serve up index.html:
136RewriteCond %{ENV:CONFIG_WRITABLE_ROOT}/%{ENV:SILVER_HOST}%{ENV:SILVER_REMAINING_URI}/index.html -f
137RewriteRule . %{ENV:CONFIG_WRITABLE_ROOT}/%{ENV:SILVER_HOST}%{ENV:SILVER_REMAINING_URI}/index.html [L]
138
139## Not per-host:
140# Refuse /index.html files (redirect):
141RewriteCond %{ENV:CONFIG_WRITABLE_ROOT}%{ENV:SILVER_REMAINING_URI} -f
142RewriteRule (.*/)index.html %{ENV:SILVER_REDIR_HOST}$1 [L,R=permanent]
143# Serve up any static files:
144RewriteCond %{ENV:CONFIG_WRITABLE_ROOT}%{ENV:SILVER_REMAINING_URI} -f
145RewriteRule . %{ENV:CONFIG_WRITABLE_ROOT}%{ENV:SILVER_REMAINING_URI} [L]
146# Add a trailing slash when necessary:
147RewriteCond %{ENV:CONFIG_WRITABLE_ROOT}%{ENV:SILVER_REMAINING_URI} -d
148RewriteCond %{ENV:SILVER_REMAINING_URI} [^/]$
149RewriteCond %{ENV:CONFIG_WRITABLE_ROOT}%{ENV:SILVER_REMAINING_URI}/index.html -f
150RewriteRule (.*) %{ENV:SILVER_REDIR_HOST}$1/ [L,R=permanent]
151# Otherwise serve up index.html:
152RewriteCond %{ENV:CONFIG_WRITABLE_ROOT}%{ENV:SILVER_REMAINING_URI}/index.html -f
153RewriteRule . %{ENV:CONFIG_WRITABLE_ROOT}%{ENV:SILVER_REMAINING_URI}/index.html [L]
154
155# Next, if the request points to something that is not a .php file,
156# then serve it up directly...
157RewriteCond %{ENV:SILVER_PLATFORM} ^php$
158RewriteCond %{ENV:SILVER_PHP_ROOT}%{ENV:SILVER_REMAINING_URI} -f
159RewriteCond %{ENV:SILVER_REMAINING_URI} !\.php$
160RewriteRule . %{ENV:SILVER_PHP_ROOT}%{ENV:SILVER_REMAINING_URI} [L]
161
162# Lastly, we run the actual PHP:
163RewriteCond %{ENV:SILVER_PLATFORM} ^php$
164RewriteRule . /usr/local/share/silverlining/mgr-scripts/master-runner.php [L]
165
166# Lastly, setup the WSGI application:
167WSGIApplicationGroup %{ENV:SILVER_INSTANCE_NAME}
168WSGIProcessGroup %{ENV:SILVER_PROCESS_GROUP}
169WSGIDaemonProcess general user=www-data processes=5 threads=1 maximum-requests=200 display-name=wsgi home=/var/www
170WSGIDaemonProcess general_debug user=www-data processes=1 threads=10 maximum-requests=200 display-name=wsgi home=/var/www
171WSGIPassAuthorization On
172
173WSGIScriptAlias / /usr/local/share/silverlining/mgr-scripts/master-runner.py
174
175</VirtualHost>