Wiki source code of Setting up the Apache HTTP Server Proxy
Last modified by Eleni Cojocariu on 2026/04/23 13:53
Show last authors
| author | version | line-number | content |
|---|---|---|---|
| 1 | {{warning}} | ||
| 2 | WIP: documentation page is being refactored and improved at: [[Apache Server Key Configurations>>documentation.xs.admin.installation.http-reverse-proxy.apache-key-configurations.WebHome]], check all its children pages for full documentation. | ||
| 3 | {{/warning}} | ||
| 4 | |||
| 5 | Example inspired from the config for https://www.myxwiki.org (with only the important parts): | ||
| 6 | |||
| 7 | * Any acces to port ##80## redirect to port ##443## | ||
| 8 | * Proxy the port ##443## to the port ##8080## (where most application servers are listening by default) | ||
| 9 | * Redirect ##/## access to ##/xwiki/## | ||
| 10 | * Make sure XWiki have enough information to know what is the source URL | ||
| 11 | * Make sure that special characters like ##/## and ##+## are allowed by Apache | ||
| 12 | * Mind the "noncanon" keyword. Without it, URLs containing semicolons will be mangled | ||
| 13 | * Enable WebSocket | ||
| 14 | |||
| 15 | {{code}} | ||
| 16 | <VirtualHost *:80> | ||
| 17 | ServerName mydomain.com | ||
| 18 | ServerAlias *.mydomain.com | ||
| 19 | |||
| 20 | RewriteEngine On | ||
| 21 | RewriteCond %{HTTPS} off | ||
| 22 | RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L] | ||
| 23 | </VirtualHost> | ||
| 24 | |||
| 25 | <VirtualHost *:443> | ||
| 26 | ServerName mydomain.com | ||
| 27 | ServerAlias *.mydomain.com | ||
| 28 | |||
| 29 | DocumentRoot /var/www/ | ||
| 30 | |||
| 31 | ErrorLog /var/log/apache2/xwiki-error.log | ||
| 32 | CustomLog /var/log/apache2/xwiki-access.log combined | ||
| 33 | |||
| 34 | RedirectMatch ^/$ /xwiki/ | ||
| 35 | |||
| 36 | <Location /xwiki> | ||
| 37 | Order Deny,Allow | ||
| 38 | Satisfy Any | ||
| 39 | </Location> | ||
| 40 | |||
| 41 | AllowEncodedSlashes NoDecode | ||
| 42 | |||
| 43 | ProxyRequests Off | ||
| 44 | <Proxy *> | ||
| 45 | Order deny,allow | ||
| 46 | Allow from all | ||
| 47 | </Proxy> | ||
| 48 | ProxyPreserveHost On | ||
| 49 | ProxyPass /xwiki http://localhost:8080/xwiki nocanon upgrade=websocket | ||
| 50 | ProxyPassReverse /xwiki http://localhost:8080/xwiki nocanon | ||
| 51 | |||
| 52 | ## Workaround for https://bz.apache.org/bugzilla/show_bug.cgi?id=58001 (ProxyPreserveHost does not includes Forwarded) | ||
| 53 | RequestHeader set Forwarded "proto=https" | ||
| 54 | |||
| 55 | # TODO: add your SSL setup | ||
| 56 | </VirtualHost> | ||
| 57 | {{/code}} |