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/libproxy.so
LoadModule rewrite_module     /usr/lib/apache/modules/mod_rewrite.so

<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
#NoCache a_domain.com another_domain.edu joes.garage_sale.com
</IfModule>

<VirtualHost *>
RewriteEngine on

# makes some requests on www.gudinna.com/gudinna to go to the new wiki url.. for backward compability with some old websearch indexes
RewriteRule ^/gudinna/([0-9]+)$ http://wiki.gudinna.com/$1 [R=permanent,L]
RewriteRule ^/gudinna/([0-9]+).html$ http://wiki.gudinna.com/$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 http://wiki.gudinna.com/recent [R=permanent]
RewriteRule ^/gudinna/help http://wiki.gudinna.com/help [R=permanent] 

# block external links to files on the wiki
RewriteCond %{HTTP_REFERER} !http://wiki.gudinna.com* [NC]       
RewriteCond %{HTTP_REFERER} !=""     
RewriteRule /gudinna_uploads/* http://217.215.6.164:8000/BustedEye.gif [L]
RewriteCond %{HTTP_REFERER} !http://wiki.gudinna.com* [NC]
RewriteCond %{HTTP_REFERER} !=""    
RewriteRule /gudinna_scheme/* http://217.215.6.164:8000/BustedEye.gif [L] 

#Makes all error documents to go to the main page or a custom error page
ErrorDocument 404 http://wiki.gudinna.com
ErrorDocument 403 http://wiki.gudinna.com

</VirtualHost>

<VirtualHost *>
ServerName wiki.gudinna.com
ErrorDocument 502 http://www.gudinna.com/searchWhenWikiDown.html

ProxyPass / http://wiki.gudinna.com:8000/gudinna/
ProxyPassReverse / http://wiki.gudinna.com:8000/gudinna/

RewriteEngine on

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

#Some fixed files requests
RewriteRule ^/comanche.gif$ http://wiki.gudinna.com:8000/comanche.gif 
RewriteRule ^/favicon.ico$ http://www.gudinna.com/favicon.ico 
RewriteRule ^/robots.txt$ http://www.gudinna.com/wiki/robots.txt
RewriteRule ^/External.gif$ http://www.gudinna.com/wiki/External.gif

#Makes apache handle wiki workload for uploads and scheme graphics.
RewriteRule ^/schemes/gudinna/(.*)$ http://www.gudinna.com/gudinna_scheme/$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} ^http://wiki.gudinna.com/(.*)$ [NC]
RewriteRule ^/uploads/(.*)$ http://www.gudinna.com/gudinna_uploads/$1 [L,R=permanent]
RewriteCond %{HTTP_REFERER} ^http://wiki.gudinna.com:8000/(.*)$ [NC]
RewriteRule ^/uploads/(.*)$ http://www.gudinna.com/gudinna_uploads/$1 [L,R=permanent] 
RewriteCond %{HTTP_REFERER} ="" 
RewriteRule ^/uploads/(.*)$ http://www.gudinna.com/gudinna_uploads/$1 [L] 
# these are the ILLEGAL requests!
RewriteCond %{HTTP_REFERER} !http://wiki.gudinna.com* [NC] 
RewriteCond %{HTTP_REFERER} !=""  
RewriteRule .*upload.* http://217.215.6.164:8000/BustedEye.gif [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
</Directory>

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

</VirtualHost>


Referenser till aktuell sida


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