Gudinna Wiki VisaÄndraBifogaVersionerUppdateratSökKarta

Hur man kan använda Apache mod_rewrite och mod_proxy i praktiken

Eftersom det är många som undrar hur Apache på Lotus är konfigurerat så har vi slängt upp en bit av httpd.conf är för allmän beskådning.

Dokumentation: @mod_rewrite, @mod_proxy

# dont forget to load the modules before using them
LoadModule proxy_module       /usr/lib/apache/modules/
LoadModule rewrite_module     /usr/lib/apache/modules/

<IfModule mod_proxy.c>
# To enable the cache as well, edit and uncomment the following lines:
# (no cacheing without CacheRoot)
CacheRoot "/var/www/proxy"
CacheSize 5
CacheGcInterval 4
CacheMaxExpire 24
CacheLastModifiedFactor 0.1
CacheDefaultExpire 1

<VirtualHost *>
RewriteEngine on

# makes some requests on to go to the new wiki url.. for backward compability with some old websearch indexes
RewriteRule ^/gudinna/([0-9]+)$$1 [R=permanent,L]
RewriteRule ^/gudinna/([0-9]+).html$$1 [R=permanent,L]

#when setting rewrite rules [R] one can use custom error codes when redirecting. [R=permanent] equals [R=301], [R] equals [R=302]
#[L] means stop processing rewrite rules after this rule L = Last

RewriteRule ^/gudinna/recent [R=permanent]
RewriteRule ^/gudinna/help [R=permanent] 

# block external links to files on the wiki
RewriteCond %{HTTP_REFERER} !* [NC]       
RewriteCond %{HTTP_REFERER} !=""     
RewriteRule /gudinna_uploads/* [L]
RewriteCond %{HTTP_REFERER} !* [NC]
RewriteCond %{HTTP_REFERER} !=""    
RewriteRule /gudinna_scheme/* [L] 

#Makes all error documents to go to the main page or a custom error page
ErrorDocument 404
ErrorDocument 403


<VirtualHost *>
ErrorDocument 502

ProxyPass /
ProxyPassReverse /

RewriteEngine on

RewriteRule ^/gudinna/(.*)$ /$1 [R=permanent] 
RewriteRule ^/gudinna / [R=permanent]

#Some fixed files requests
RewriteRule ^/comanche.gif$ 
RewriteRule ^/favicon.ico$ 
RewriteRule ^/robots.txt$
RewriteRule ^/External.gif$

#Makes apache handle wiki workload for uploads and scheme graphics.
RewriteRule ^/schemes/gudinna/(.*)$$1 [R=permanent]  

#Some lines to block skript-kiddies from linking driectly to images on the wiki
# %{HTTP_REFERER} =""    is when a user presses the reload button
# first som eline sfor some legal requests.. (i think these lines are unnececery)
RewriteCond %{HTTP_REFERER} ^*)$ [NC]
RewriteRule ^/uploads/(.*)$$1 [L,R=permanent]
RewriteCond %{HTTP_REFERER} ^*)$ [NC]
RewriteRule ^/uploads/(.*)$$1 [L,R=permanent] 
RewriteCond %{HTTP_REFERER} ="" 
RewriteRule ^/uploads/(.*)$$1 [L] 
# these are the ILLEGAL requests!
RewriteCond %{HTTP_REFERER} !* [NC] 
RewriteCond %{HTTP_REFERER} !=""  
RewriteRule .*upload.* [L] 

Alias /schemes/gudinna/ "/var/www/htdocs/gudinna_scheme/"
<Directory "/var/www/htdocs/gudinna_scheme">
 Options Indexes MultiViews
 AllowOverride None
 order allow,deny
 Allow from all

#Forces edit page requests to go to the slower wiki for non proxy discrimination
RewriteRule ^/(.*.edit)$$1 
RewriteRule ^/(.*.upload)$$1  
RewriteRule ^/(.*.attach)$$1 
RewriteRule ^/(.*.save)$$1 
RewriteRule ^/(.*.append)$$1 


Referenser till aktuell sida

Frivillig gåva till stöd för driften av Gudinna Wiki :