Wiki source code of Configure Apache HTTP Server as a Proxy on a Linux OS
Last modified by Eleni Cojocariu on 2026/10/05 11:06
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 Linux system, using the [[directives XWiki needs>>doc:documentation.xs.admin.installation.http-reverse-proxy.apache-key-configurations.WebHome]]. This procedure serves the wiki over plain ##HTTP## on port ##80##; [[Configure HTTPS for the Apache HTTP Proxy Server>>doc:documentation.xs.admin.installation.http-reverse-proxy.apache-key-configurations.configure-https.WebHome]] adds ##HTTPS## on top of it. The commands are those of a Debian-based distribution. | ||
| 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. [[Install Apache HTTP Server>>https://httpd.apache.org/]], version 2.4.47 or later, which is what the ##upgrade=websocket## option below needs. | ||
| 5 | 1. Enable the modules the configuration below needs: {{code language="none"}}sudo a2enmod proxy proxy_http headers{{/code}}. | ||
| 6 | 1. Create the file ##/etc/apache2/sites-available/xwiki.conf## with the following content:((( | ||
| 7 | {{code language="apacheconf"}} | ||
| 8 | <VirtualHost *:80> | ||
| 9 | ServerName localhost | ||
| 10 | |||
| 11 | ErrorLog ${APACHE_LOG_DIR}/xwiki-error.log | ||
| 12 | CustomLog ${APACHE_LOG_DIR}/xwiki-access.log combined | ||
| 13 | |||
| 14 | RedirectMatch ^/$ /xwiki/ | ||
| 15 | |||
| 16 | <Location /xwiki> | ||
| 17 | Require all granted | ||
| 18 | </Location> | ||
| 19 | |||
| 20 | AllowEncodedSlashes NoDecode | ||
| 21 | |||
| 22 | RequestHeader unset Forwarded | ||
| 23 | RequestHeader unset X-Forwarded-Host | ||
| 24 | RequestHeader unset X-Forwarded-Proto | ||
| 25 | |||
| 26 | ProxyRequests Off | ||
| 27 | ProxyPreserveHost On | ||
| 28 | |||
| 29 | ProxyPass /xwiki http://localhost:8080/xwiki nocanon upgrade=websocket | ||
| 30 | ProxyPassReverse /xwiki http://localhost:8080/xwiki | ||
| 31 | </VirtualHost> | ||
| 32 | {{/code}} | ||
| 33 | ))) | ||
| 34 | 1. Enable the site: {{code language="none"}}sudo a2ensite xwiki{{/code}}. | ||
| 35 | 1. Check the configuration: {{code language="none"}}sudo apachectl configtest{{/code}}. | ||
| 36 | 1. Reload Apache: {{code language="none"}}sudo systemctl reload apache2{{/code}}. | ||
| 37 | 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. |