1. # Autogenerated httpd.conf file for Foswiki.
  2. # Generated at http://foswiki.org/Support/ApacheConfigGenerator?
  3. vhost=wiki.mydomain.com;port=;dir=/var/lib/foswiki;symlink=;pathurl=/;shorterurls=enabled;engine=CGI;fastcgimodule=fastcgi;apver=2;allowconf=;requireconf=;lo
  4. ginmanager=Template;htpath=;errordocument=UserRegistration;errorcustom=;phpinstalled=PHP4;blockpubhtml=on;blocktrashpub=on;controlattach=on;blockspiders=on;f
  5. oswikiversion=1.1
  6. # For Foswiki version 1.1
  7. <VirtualHost *:443>
  8. ServerAdmin [email protected]
  9. DocumentRoot "/var/lib/foswiki"
  10. ServerName wiki.mydomain.com
  11. ServerAlias wiki.mydomain.com
  12. SSLEngine On
  13. SSLCertificateFile /etc/apache2/ssl/apache.pem
  14. # The Alias defines a url that points to the root of the Foswiki installation.
  15. # The first parameter will be part of the URL to your installation e.g.
  16. # http://my.co.uk/foswiki/bin/view/...
  17. # The second parameter must point to the physical path on your disc.
  18. ScriptAlias /bin "/var/lib/foswiki/bin"
  19. # The following Alias is used to access files in the pub directory (attachments etc)
  20. # It must come _after_ the ScriptAlias.
  21. # If short URLs are enabled, and any other local directories or files need to be accessed directly, they
  22. # must also be specified in an Alias statement, and must not conflict with a web name.
  23. Alias /pub "/var/lib/foswiki/pub"
  24. Alias /robots.txt "/var/lib/foswiki/robots.txt"
  25. RewriteEngine on
  26. # Rewriting is required for Short URLs, and Attachment redirecting to viewfile
  27. #RewriteEngine on
  28. #RewriteLog "/var/log/apache/rewrite.log"
  29. #RewriteLogLevel 0
  30. # short urls
  31. Alias / "/var/lib/foswiki/bin/view/"
  32. RewriteRule ^/+bin/+view/+(.*) /$1 [L,NE,R]
  33. RewriteRule ^/+bin/+view$ / [L,NE,R]
  34. #
  35. # Dont rewrite any other /bin URLs
  36. #
  37. RewriteRule ^/bin/(.*)$ - [L,PT] # bin, stop rewriting
  38. #
  39. # Dont rewrite internal requests or robots.txt
  40. #
  41. RewriteCond %{IS_SUBREQ} ^true$ [OR]
  42. RewriteCond %{REQUEST_URI} ^/robots.txt$
  43. RewriteRule .* - [L]
  44. #
  45. # Protect attachments by rewriting to the "viewfile" script
  46. #
  47. # Permit some safe exceptions to avoid viewfile overhead
  48. # Any gif/jpg/ico in /pub, and any files in /pub/System or any WebPreferences:
  49. # pass through unmodified
  50. RewriteCond %{REQUEST_URI} ^/pub/[^/]+\.(gif|jpe?g|ico)$ [NC,OR]
  51. RewriteCond %{REQUEST_URI} ^/pub/System/(.*)$ [OR]
  52. RewriteCond %{REQUEST_URI} ^/pub/([^/]+/)+WebPreferences/([^/]+)$
  53. RewriteRule ^/pub/.* - [L,PT]
  54. # Optional - do not rewrite /pub/images if ImageGalleryPlugin is installed - path is incompatible with viewfile
  55. #RewriteRule ^/+pub/+images/+.*$ - [L,PT]
  56. # If it makes it here, rewrite as viewfile
  57. RewriteRule ^/+pub/+(.*)$ /bin/viewfile/$1 [L,PT]
  58. # Block access to typical spam related attachments
  59. # Except the Foswiki directory which is read only and does have attached html files.
  60. SetEnvIf Request_URI "/pub/.*\.[hH][tT][mM][lL]?$" blockAccess
  61. SetEnvIf Request_URI "/pub/System/.*\.[hH][tT][mM][lL]?$" !blockAccess
  62. # This enables access to the documents in the Foswiki root directory
  63. <Directory "/var/lib/foswiki">
  64. # Order Allow,Deny
  65. # Allow from all
  66. # Deny from env=blockAccess
  67. Order deny,allow
  68. Deny from all
  69. ##Order allow,deny
  70. #Allow from 10.8.
  71. #Allow from 10.8.0.0
  72. #Allow from 10.8.0.1
  73. #Allow from 127.0.0.1
  74. </Directory>
  75. # This specifies the options on the Foswiki scripts directory. The ExecCGI
  76. # and SetHandler tell apache that it contains scripts. "Allow from all"
  77. # lets any IP address access this URL.
  78. # Note: If you use SELinux, you also have to "Allow httpd cgi support" in your SELinux policies
  79. <Directory "/var/lib/foswiki/bin">
  80. Order deny,allow
  81. Deny from all
  82. Options +ExecCGI -FollowSymLinks
  83. SetHandler cgi-script
  84. # Password file for Foswiki users
  85. AuthUserFile "/var/lib/foswiki/data/.htpasswd"
  86. AuthName 'Enter your WikiName: (First name and last name, no space, no dots, capitalized, e.g. JohnSmith). Cancel to register if you do not have one.'
  87. AuthType Basic
  88. # File to return on access control error (e.g. wrong password)
  89. ErrorDocument 401 /System/UserRegistration
  90. # Limit access to configure to specific IP address(es) and user(s).
  91. # Make sure configure is not open to the general public.
  92. # It exposes system details that can help attackers.
  93. # cf. http://foswiki.org/Support/ProtectingYourConfiguration for details.
  94. <FilesMatch "^(configure)$">
  95. #SetHandler cgi-script
  96. #Satisfy All
  97. SetHandler cgi-script
  98. Order Deny,Allow
  99. Deny from all
  100. Require user epross
  101. Satisfy Any
  102. ErrorDocument 401 default
  103. </FilesMatch>
  104. # <FilesMatch ".*">
  105. # require valid-user
  106. # </FilesMatch>
  107. </Directory>
  108. # This sets the options on the pub directory, which contains attachments and
  109. # other files like CSS stylesheets and icons. AllowOverride None stops a
  110. # user installing a .htaccess file that overrides these options.
  111. # Note that files in pub are *not* protected by Foswiki Access Controls,
  112. # so if you want to control access to files attached to topics you need to
  113. # block access to the specific directories same way as the ApacheConfigGenerator
  114. # blocks access to the pub directory of the Trash web
  115. <Directory "/var/lib/foswiki/pub">
  116. Options None
  117. Options -FollowSymLinks
  118. AllowOverride None
  119. # Order Allow,Deny
  120. # Allow from all
  121. Order deny,allow
  122. Deny from all
  123. Deny from env=blockAccess
  124. ErrorDocument 404 /bin/viewfile
  125. # Disable execution of PHP scripts
  126. php_admin_flag engine off
  127. # This line will redefine the mime type for the most common types of scripts
  128. AddType text/plain .shtml .php .php3 .phtml .phtm .pl .py .cgi
  129. #
  130. #add an Expires header that is sufficiently in the future that the browser does not even ask if its uptodate
  131. # reducing the load on the server significantly
  132. #IF you can, you should enable this - it _will_ improve your Foswiki experience, even if you set it to under one day.
  133. # you may need to enable expires_module in your main apache config
  134. #LoadModule expires_module libexec/httpd/mod_expires.so
  135. #AddModule mod_expires.c
  136. #<ifmodule mod_expires.c>
  137. # <filesmatch "\.(jpe?g|gif|png|css(\.gz)?|js(\.gz)?|ico)$">
  138. # ExpiresActive on
  139. # ExpiresDefault "access plus 11 days"
  140. # </filesmatch>
  141. #</ifmodule>
  142. #
  143. # Serve pre-compressed versions of .js and .css files, if they exist
  144. # Some browsers do not handle this correctly, which is why it is disabled by default
  145. # <FilesMatch "\.(js|css)$">
  146. # RewriteEngine on
  147. # RewriteCond %{HTTP:Accept-encoding} gzip
  148. # RewriteCond %{REQUEST_FILENAME}.gz -f
  149. # RewriteRule ^(.*)$ %{REQUEST_URI}.gz [L,QSA]
  150. # </FilesMatch>
  151. # <FilesMatch "\.(js|css)\?.*$">
  152. # RewriteEngine on
  153. # RewriteCond %{HTTP:Accept-encoding} gzip
  154. # RewriteCond %{REQUEST_FILENAME}.gz -f
  155. # RewriteRule ^([^?]*)\?(.*)$ $1.gz?$2 [L]
  156. # </FilesMatch>
  157. # <FilesMatch "\.js\.gz(\?.*)?$">
  158. # AddEncoding x-gzip .gz
  159. # AddType application/x-javascript .gz
  160. # </FilesMatch>
  161. # <FilesMatch "\.css\.gz(\?.*)?$">
  162. # AddEncoding x-gzip .gz
  163. # AddType text/css .gz
  164. # </FilesMatch>
  165. </Directory>
  166. # Spammers are known to attach their stuff and then move it to trash where it remains unnoticed.
  167. # We prevent viewing any attachments directly from pub
  168. <Directory "/var/lib/foswiki/pub/Trash">
  169. deny from all
  170. </Directory>
  171. # Security note: All other directories should be set so
  172. # that they are *not* visible as URLs, so we set them as =deny from all=.
  173. <Directory "/var/lib/foswiki/data">
  174. deny from all
  175. </Directory>
  176. <Directory "/var/lib/foswiki/templates">
  177. deny from all
  178. </Directory>
  179. <Directory "/var/lib/foswiki/lib">
  180. deny from all
  181. </Directory>
  182. <Directory "/var/lib/foswiki/locale">
  183. deny from all
  184. </Directory>
  185. <Directory "/var/lib/foswiki/tools">
  186. deny from all
  187. </Directory>
  188. <Directory "/var/lib/foswiki/working">
  189. deny from all
  190. </Directory>
  191. # We set an environment variable called blockAccess.
  192. #
  193. # Setting a BrowserMatchNoCase to ^$ is important. It prevents Foswiki from
  194. # including its own topics as URLs and also prevents other Foswikis from
  195. # doing the same. This is important to prevent the most obvious
  196. # Denial of Service attacks.
  197. #
  198. # You can expand this by adding more BrowserMatchNoCase statements to
  199. # block evil browser agents trying to crawl your Foswiki
  200. #
  201. # Example:
  202. # BrowserMatchNoCase ^SiteSucker blockAccess
  203. # BrowserMatchNoCase ^$ blockAccess
  204. BrowserMatchNoCase ^Accoona blockAccess
  205. BrowserMatchNoCase ^ActiveAgent blockAccess
  206. BrowserMatchNoCase ^Attache blockAccess
  207. BrowserMatchNoCase BecomeBot blockAccess
  208. BrowserMatchNoCase ^bot blockAccess
  209. BrowserMatchNoCase Charlotte/ blockAccess
  210. BrowserMatchNoCase ^ConveraCrawler blockAccess
  211. BrowserMatchNoCase ^CrownPeak-HttpAgent blockAccess
  212. BrowserMatchNoCase ^EmailCollector blockAccess
  213. BrowserMatchNoCase ^EmailSiphon blockAccess
  214. BrowserMatchNoCase ^e-SocietyRobot blockAccess
  215. BrowserMatchNoCase ^Exabot blockAccess
  216. BrowserMatchNoCase ^FAST blockAccess
  217. BrowserMatchNoCase ^FDM blockAccess
  218. BrowserMatchNoCase ^GetRight/6.0a blockAccess
  219. BrowserMatchNoCase ^GetWebPics blockAccess
  220. BrowserMatchNoCase ^Gigabot blockAccess
  221. BrowserMatchNoCase ^gonzo1 blockAccess
  222. BrowserMatchNoCase ^Google\sSpider blockAccess
  223. BrowserMatchNoCase ^ichiro blockAccess
  224. BrowserMatchNoCase ^ie_crawler blockAccess
  225. BrowserMatchNoCase ^iGetter blockAccess
  226. BrowserMatchNoCase ^IRLbot blockAccess
  227. BrowserMatchNoCase Jakarta blockAccess
  228. BrowserMatchNoCase ^Java blockAccess
  229. BrowserMatchNoCase ^KrakSpider blockAccess
  230. BrowserMatchNoCase ^larbin blockAccess
  231. BrowserMatchNoCase ^LeechGet blockAccess
  232. BrowserMatchNoCase ^LinkWalker blockAccess
  233. BrowserMatchNoCase ^Lsearch blockAccess
  234. BrowserMatchNoCase ^Microsoft blockAccess
  235. BrowserMatchNoCase MJ12bot blockAccess
  236. BrowserMatchNoCase MSIECrawler blockAccess
  237. BrowserMatchNoCase ^MSRBOT blockAccess
  238. BrowserMatchNoCase ^noxtrumbot blockAccess
  239. BrowserMatchNoCase ^NutchCVS blockAccess
  240. BrowserMatchNoCase ^RealDownload blockAccess
  241. BrowserMatchNoCase ^Rome blockAccess
  242. BrowserMatchNoCase ^Roverbot blockAccess
  243. BrowserMatchNoCase ^schibstedsokbot blockAccess
  244. BrowserMatchNoCase ^Seekbot blockAccess
  245. BrowserMatchNoCase ^SiteSnagger blockAccess
  246. BrowserMatchNoCase ^SiteSucker blockAccess
  247. BrowserMatchNoCase ^Snapbot blockAccess
  248. BrowserMatchNoCase ^sogou blockAccess
  249. BrowserMatchNoCase ^SpiderKU blockAccess
  250. BrowserMatchNoCase ^SpiderMan blockAccess
  251. BrowserMatchNoCase ^Squid blockAccess
  252. BrowserMatchNoCase ^Teleport blockAccess
  253. BrowserMatchNoCase ^User-Agent\: blockAccess
  254. BrowserMatchNoCase VoilaBot blockAccess
  255. BrowserMatchNoCase ^voyager blockAccess
  256. BrowserMatchNoCase ^w3search blockAccess
  257. BrowserMatchNoCase ^Web\sDownloader blockAccess
  258. BrowserMatchNoCase ^WebCopier blockAccess
  259. BrowserMatchNoCase ^WebDevil blockAccess
  260. BrowserMatchNoCase ^WebSec blockAccess
  261. BrowserMatchNoCase ^WebVac blockAccess
  262. BrowserMatchNoCase ^Webwhacker blockAccess
  263. BrowserMatchNoCase ^Webzip blockAccess
  264. BrowserMatchNoCase ^Wells blockAccess
  265. BrowserMatchNoCase ^WhoWhere blockAccess
  266. BrowserMatchNoCase www\.netforex\.org blockAccess
  267. BrowserMatchNoCase ^WX_mail blockAccess
  268. BrowserMatchNoCase ^yacybot blockAccess
  269. BrowserMatchNoCase ^ZIBB blockAccess
  270. # Setting the NO_FOSWIKI_SESSION environment variable prevents a
  271. # session being created for the Google Search Appliance bot. This
  272. # is useful if you have the Google Search Appliance installed on
  273. # your intranet, as they can be very aggressive when indexing, creating
  274. # a lot of session files and slowing Foswiki down.
  275. # You can also set this environment variable for public sites, to
  276. # prevent Google and other search engines' bots. However, these tend
  277. # to index your site a lot less often than the Google Search Appliance.
  278. # *Works on Foswiki 1.1 and later only*
  279. BrowserMatch "^gsa-crawler" NO_FOSWIKI_SESSION
  280. BrowserMatchNoCase ^$ blockAccess
  281. </VirtualHost>