Setting up the Apache HTTP Server Proxy

Last modified by Tom Wise on 2024/05/03

Example inpired from (with only the important parts):

  • any acces to port 80 redirect to port 443
  • proxy the port 443 to the port 8080 (where most application servers are listening by default)
  • redirect / access to /xwiki/
  • make sure XWiki have enough information to know what is the source URL
  • make sure that special characters like / and + are allowed
  • Mind the "noncanon" keyword. Without it, URLs containing semicolons will be mangled
<VirtualHost *:80>
 ServerAlias *

 RewriteEngine On
 RewriteCond %{HTTPS} off
 RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]

<VirtualHost *:443>
 ServerAlias *

 DocumentRoot /var/www/

 ErrorLog /var/log/apache2/xwiki-error.log
 CustomLog /var/log/apache2/xwiki-access.log combined

 RedirectMatch ^/$ /xwiki/

 <Location /xwiki>
   Order Deny,Allow
   Satisfy Any

 AllowEncodedSlashes NoDecode

 ProxyRequests Off
 <Proxy *>
   Order deny,allow
   Allow from all
 ProxyPreserveHost On
 ProxyPass /xwiki http://localhost:8080/xwiki nocanon upgrade=websocket
 ProxyPassReverse /xwiki http://localhost:8080/xwiki nocanon

  ## Workaround for (ProxyPreserveHost does not includes Forwarded)
 RequestHeader set Forwarded "proto=https"

  # TODO: add your SSL setup

Get Connected