Wiki source code of Configure Apache HTTP Server as a Proxy on a Windows OS
Last modified by Eleni Cojocariu-testing account on 2026/08/18 11:38
Show last authors
| author | version | line-number | content |
|---|---|---|---|
| 1 | Apache HTTP Server forwards requests to the XWiki [[Servlet Container>>doc:documentation.xs.admin.installation.methods.install-xwiki-war.configure-servlet-container.WebHome]] on a Windows system, using the [[directives XWiki needs>>doc:documentation.xs.admin.installation.http-reverse-proxy.apache-key-configurations.WebHome]]. Windows has no Apache package, so the server is unpacked from an archive and registered as a Windows service; everything else is configured in the single ##httpd.conf## file. | ||
| 2 | |||
| 3 | 1. Make sure your wiki is running and reachable locally, for example at {{code language="none"}}http://localhost:8080/xwiki{{/code}}. | ||
| 4 | 1. Download an [[Apache Lounge>>https://www.apachelounge.com/download/]] build of Apache HTTP Server, version 2.4.47 or later, which is what the ##upgrade=websocket## option below needs. | ||
| 5 | 1. Extract the archive to ##C:\Apache24##. | ||
| 6 | 1. Set {{code language="none"}}Define SRVROOT "C:/Apache24"{{/code}} in ##C:\Apache24\conf\httpd.conf## to the directory you extracted to. | ||
| 7 | 1. Uncomment the {{code language="none"}}#ServerName www.example.com:80{{/code}} line in the same file and change it to {{code language="none"}}ServerName localhost:80{{/code}}. | ||
| 8 | 1. Uncomment the three modules the configuration below needs, in the same file:((( | ||
| 9 | {{code language="apacheconf"}} | ||
| 10 | LoadModule proxy_module modules/mod_proxy.so | ||
| 11 | LoadModule proxy_http_module modules/mod_proxy_http.so | ||
| 12 | LoadModule headers_module modules/mod_headers.so | ||
| 13 | {{/code}} | ||
| 14 | ))) | ||
| 15 | 1. Add the following block at the end of the same file:((( | ||
| 16 | {{code language="apacheconf"}} | ||
| 17 | <VirtualHost *:80> | ||
| 18 | ServerName localhost | ||
| 19 | |||
| 20 | RedirectMatch ^/$ /xwiki/ | ||
| 21 | |||
| 22 | <Location /xwiki> | ||
| 23 | Require all granted | ||
| 24 | </Location> | ||
| 25 | |||
| 26 | AllowEncodedSlashes NoDecode | ||
| 27 | |||
| 28 | RequestHeader unset Forwarded | ||
| 29 | RequestHeader unset X-Forwarded-Host | ||
| 30 | RequestHeader unset X-Forwarded-Proto | ||
| 31 | |||
| 32 | ProxyRequests Off | ||
| 33 | ProxyPreserveHost On | ||
| 34 | |||
| 35 | ProxyPass /xwiki http://localhost:8080/xwiki nocanon upgrade=websocket | ||
| 36 | ProxyPassReverse /xwiki http://localhost:8080/xwiki | ||
| 37 | </VirtualHost> | ||
| 38 | {{/code}} | ||
| 39 | ))) | ||
| 40 | 1. Register Apache as a Windows service: open a Command Prompt as Administrator and run {{code language="none"}}cd C:\Apache24\bin{{/code}} then {{code language="none"}}httpd.exe -k install{{/code}}. | ||
| 41 | 1. Start the service: {{code language="none"}}httpd.exe -k start{{/code}}. After any later change to ##httpd.conf##, use {{code language="none"}}httpd.exe -k restart{{/code}} instead. | ||
| 42 | 1. Open {{code language="none"}}http://localhost{{/code}} in a browser. Apache redirects to {{code language="none"}}http://localhost/xwiki/{{/code}} and the wiki loads through port ##80##, with no port number in the address. |