/silverlining/server-root/etc/apache2/sites-enabled/wsgi_runner
#! | 175 lines | 148 code | 27 blank | 0 comment | 0 complexity | 9f30d3952e3bdb93632f8e873e03d386 MD5 | raw file
Possible License(s): GPL-2.0
- RewriteLock /var/lock/apache2/rewrite.lck
- <VirtualHost 127.0.0.1:8080>
- ServerAdmin webmaster@localhost
- #DocumentRoot /var/www
- <Directory />
- Options FollowSymLinks
- AllowOverride None
- </Directory>
- <Directory /var/www/>
- Options Indexes FollowSymLinks MultiViews
- AllowOverride None
- Order allow,deny
- allow from all
- </Directory>
- #ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
- #<Directory "/usr/lib/cgi-bin">
- # AllowOverride None
- # Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
- # Order allow,deny
- # Allow from all
- #</Directory>
- <LocationMatch />
- # Insert filter
- SetOutputFilter DEFLATE
- # Netscape 4.x has some problems...
- BrowserMatch ^Mozilla/4 gzip-only-text/html
- # Netscape 4.06-4.08 have some more problems
- BrowserMatch ^Mozilla/4\.0[678] no-gzip
- # MSIE masquerades as Netscape, but it is fine
- BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
- # Don't compress images
- SetEnvIfNoCase Request_URI \
- \.(?:gif|jpe?g|png)$ no-gzip dont-vary
- # Make sure proxies don't deliver the wrong content
- Header append Vary User-Agent env=!dont-vary
- </LocationMatch>
- ErrorLog /var/log/apache2/error.log
- # Possible values include: debug, info, notice, warn, error, crit,
- # alert, emerg.
- LogLevel warn
- ## FIXME: %l and %u are always -; why bother?
- # 10.5.2.1 - - [Date] "GET /foo HTTP/1.1" 200 9430 "http://ref" "Mozilla/blah" thisserver.com "some_app" 103000
- 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
- CustomLog /var/log/apache2/access.log wsgi_combined
- ## Python/WSGI setup:
- RewriteEngine on
- ## Uncomment if you want to understand what is happening here:
- #RewriteLog /var/log/apache2/rewrite.log
- #RewriteLogLevel 5
- # Strip www. from all (non-https) domains:
- RewriteCond %{SERVER_PORT} ^8080$
- RewriteCond %{HTTP_HOST} ^www\.(.*)$
- RewriteRule (.*) http://%1$1 [L,R=permanent]
- RewriteCond %{HTTP_HOST} ^(.*)(:8080)?$
- RewriteRule . - [E=SILVER_REDIR_HOST:http://%1]
- RewriteCond %{HTTP:X-Forwarded-For} ^([0-9.]+)
- RewriteRule . - [E=SILVER_FORWARDED:%1]
- RewriteMap appdata prg:/usr/local/share/silverlining/mgr-scripts/rewrite-map.py
- RewriteCond ${appdata:%{HTTP_HOST}^%{REQUEST_URI}} (.*)
- RewriteRule . - [E=SILVER_APP_DATA:%1]
- # Special case redirect:
- RewriteCond %{ENV:SILVER_APP_DATA} ^addslash$
- RewriteRule (.*) %{ENV:SILVER_REDIR_HOST}$1/ [L,R=permanent]
- RewriteCond %{ENV:SILVER_APP_DATA} ^error:(.*)$
- RewriteRule . /usr/local/share/silverlining/error/routing-error.html [R=500,L,E=ERROR_MSG:%1]
- RewriteCond %{ENV:SILVER_APP_DATA} (.*)\|(.*)\|(.*)\|(.*)\|(.*)\|(.*)\|(.*)
- RewriteRule . - [E=SILVER_MATCH_PATH:%1]
- RewriteCond %{ENV:SILVER_APP_DATA} (.*)\|(.*)\|(.*)\|(.*)\|(.*)\|(.*)\|(.*)
- RewriteRule . - [E=SILVER_INSTANCE_NAME:%2]
- RewriteCond %{ENV:SILVER_APP_DATA} (.*)\|(.*)\|(.*)\|(.*)\|(.*)\|(.*)\|(.*)
- RewriteRule . - [E=SILVER_PROCESS_GROUP:%3]
- RewriteCond %{ENV:SILVER_APP_DATA} (.*)\|(.*)\|(.*)\|(.*)\|(.*)\|(.*)\|(.*)
- RewriteRule . - [E=CONFIG_WRITABLE_ROOT:%4]
- RewriteCond %{ENV:SILVER_APP_DATA} (.*)\|(.*)\|(.*)\|(.*)\|(.*)\|(.*)\|(.*)
- RewriteRule . - [E=SILVER_PLATFORM:%5]
- RewriteCond %{ENV:SILVER_APP_DATA} (.*)\|(.*)\|(.*)\|(.*)\|(.*)\|(.*)\|(.*)
- RewriteRule . - [E=SILVER_PHP_ROOT:%6]
- RewriteCond %{ENV:SILVER_APP_DATA} (.*)\|(.*)\|(.*)\|(.*)\|(.*)\|(.*)\|(.*)
- RewriteRule . - [E=SILVER_REMAINING_URI:%7]
- RewriteCond %{ENV:SILVER_INSTANCE_NAME} ^([^.]*)\.
- RewriteRule . - [E=SILVER_APP_NAME:%1]
- RewriteCond %{HTTP_HOST} ^(.*)(?:\:\d+)?$
- RewriteRule . - [E=SILVER_HOST:%1]
- # Refuse /index.html files (redirect):
- RewriteCond /var/www/%{ENV:SILVER_INSTANCE_NAME}/static%{ENV:SILVER_REMAINING_URI} -f
- RewriteRule (.*/)index.html %{ENV:SILVER_REDIR_HOST}$1 [L,R=permanent]
- # Serve up any static files:
- RewriteCond /var/www/%{ENV:SILVER_INSTANCE_NAME}/static%{ENV:SILVER_REMAINING_URI} -f
- RewriteRule . /var/www/%{ENV:SILVER_INSTANCE_NAME}/static%{ENV:SILVER_REMAINING_URI} [L]
- # Add a trailing slash when necessary:
- RewriteCond /var/www/%{ENV:SILVER_INSTANCE_NAME}/static%{ENV:SILVER_REMAINING_URI} -d
- RewriteCond %{ENV:SILVER_REMAINING_URI} [^/]$
- RewriteCond /var/www/%{ENV:SILVER_INSTANCE_NAME}/static%{ENV:SILVER_REMAINING_URI}/index.html -f
- RewriteRule (.*) %{ENV:SILVER_REDIR_HOST}$1/ [L,R=permanent]
- # Otherwise serve up index.html:
- RewriteCond /var/www/%{ENV:SILVER_INSTANCE_NAME}/static%{ENV:SILVER_REMAINING_URI}/index.html -f
- RewriteRule . /var/www/%{ENV:SILVER_INSTANCE_NAME}/static%{ENV:SILVER_REMAINING_URI}/index.html [L]
- ## FIXME: even when there is no writable root, these all get run:
- ## Repeat static serving for writable-root files; this entire stanza
- ## is repeated twice, first using the host-specific location, then a
- ## more general location:
- ## Per-host:
- # Refuse /index.html files (redirect):
- RewriteCond %{ENV:CONFIG_WRITABLE_ROOT}/%{ENV:SILVER_HOST}%{ENV:SILVER_REMAINING_URI} -f
- RewriteRule (.*/)index.html %{ENV:SILVER_REDIR_HOST}$1 [L,R=permanent]
- # Serve up any static files:
- RewriteCond %{ENV:CONFIG_WRITABLE_ROOT}/%{ENV:SILVER_HOST}%{ENV:SILVER_REMAINING_URI} -f
- RewriteRule . %{ENV:CONFIG_WRITABLE_ROOT}/%{ENV:SILVER_HOST}%{ENV:SILVER_REMAINING_URI} [L]
- # Add a trailing slash when necessary:
- RewriteCond %{ENV:CONFIG_WRITABLE_ROOT}/%{ENV:SILVER_HOST}%{ENV:SILVER_REMAINING_URI} -d
- RewriteCond %{ENV:SILVER_REMAINING_URI} [^/]$
- RewriteCond %{ENV:CONFIG_WRITABLE_ROOT}/%{ENV:SILVER_HOST}%{ENV:SILVER_REMAINING_URI}/index.html -f
- RewriteRule (.*) %{ENV:SILVER_REDIR_HOST}$1/ [L,R=permanent]
- # Otherwise serve up index.html:
- RewriteCond %{ENV:CONFIG_WRITABLE_ROOT}/%{ENV:SILVER_HOST}%{ENV:SILVER_REMAINING_URI}/index.html -f
- RewriteRule . %{ENV:CONFIG_WRITABLE_ROOT}/%{ENV:SILVER_HOST}%{ENV:SILVER_REMAINING_URI}/index.html [L]
- ## Not per-host:
- # Refuse /index.html files (redirect):
- RewriteCond %{ENV:CONFIG_WRITABLE_ROOT}%{ENV:SILVER_REMAINING_URI} -f
- RewriteRule (.*/)index.html %{ENV:SILVER_REDIR_HOST}$1 [L,R=permanent]
- # Serve up any static files:
- RewriteCond %{ENV:CONFIG_WRITABLE_ROOT}%{ENV:SILVER_REMAINING_URI} -f
- RewriteRule . %{ENV:CONFIG_WRITABLE_ROOT}%{ENV:SILVER_REMAINING_URI} [L]
- # Add a trailing slash when necessary:
- RewriteCond %{ENV:CONFIG_WRITABLE_ROOT}%{ENV:SILVER_REMAINING_URI} -d
- RewriteCond %{ENV:SILVER_REMAINING_URI} [^/]$
- RewriteCond %{ENV:CONFIG_WRITABLE_ROOT}%{ENV:SILVER_REMAINING_URI}/index.html -f
- RewriteRule (.*) %{ENV:SILVER_REDIR_HOST}$1/ [L,R=permanent]
- # Otherwise serve up index.html:
- RewriteCond %{ENV:CONFIG_WRITABLE_ROOT}%{ENV:SILVER_REMAINING_URI}/index.html -f
- RewriteRule . %{ENV:CONFIG_WRITABLE_ROOT}%{ENV:SILVER_REMAINING_URI}/index.html [L]
- # Next, if the request points to something that is not a .php file,
- # then serve it up directly...
- RewriteCond %{ENV:SILVER_PLATFORM} ^php$
- RewriteCond %{ENV:SILVER_PHP_ROOT}%{ENV:SILVER_REMAINING_URI} -f
- RewriteCond %{ENV:SILVER_REMAINING_URI} !\.php$
- RewriteRule . %{ENV:SILVER_PHP_ROOT}%{ENV:SILVER_REMAINING_URI} [L]
- # Lastly, we run the actual PHP:
- RewriteCond %{ENV:SILVER_PLATFORM} ^php$
- RewriteRule . /usr/local/share/silverlining/mgr-scripts/master-runner.php [L]
- # Lastly, setup the WSGI application:
- WSGIApplicationGroup %{ENV:SILVER_INSTANCE_NAME}
- WSGIProcessGroup %{ENV:SILVER_PROCESS_GROUP}
- WSGIDaemonProcess general user=www-data processes=5 threads=1 maximum-requests=200 display-name=wsgi home=/var/www
- WSGIDaemonProcess general_debug user=www-data processes=1 threads=10 maximum-requests=200 display-name=wsgi home=/var/www
- WSGIPassAuthorization On
- WSGIScriptAlias / /usr/local/share/silverlining/mgr-scripts/master-runner.py
- </VirtualHost>