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