Apache2 Reverse Proxy Configuration

Hi folks,

I’m really close to getting XWiki up and running the way I want, but at the moment I’m only able to access it from within my network.

I’m trying to employ the same exact Apache2 reverse proxy approach as I use successfully with other resources on my network, but it’s not working for XWiki. I’m running Debian 12 and XWiki 15.9 installed via the .deb package. I’ve gone through several other reverse proxy posts on here that I’ve found to no success.

I have a machine named ‘proxy’ that receives all my network’s web traffic. Its 000-default.conf file looks like:

<VirtualHost *:80>

	RewriteEngine on

        [other omitted rewrites]

	RewriteCond %{SERVER_NAME} ^cms
	RewriteRule ^/(.*)$ https://cms//$1 [R=301]

	ServerAdmin webmaster@localhost
	DocumentRoot /var/www/html

	ErrorLog ${APACHE_LOG_DIR}/error.log
	CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

The default-ssl.conf file looks like this:

<IfModule mod_ssl.c>
       	<VirtualHost *:443>
		ServerName cms.example.com
		
		ErrorLog ${APACHE_LOG_DIR}/cms-error.log
		CustomLog ${APACHE_LOG_DIR}/cms-access.log combined

		SSLCertificateFile	/etc/letsencrypt/live/example.com/fullchain.pem
		SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem

		ProxyPreserveHost On
		ProxyPass / http://cms:8080/xwiki/
		ProxyPassReverse / http://cms:8080/xwiki/

	</VirtualHost>
</IfModule>

The .conf files on the cms machine are pure vanilla.

On my local network, I can go to http://cms:8080/ and everything works just fine. When I try to visit cms.example.com, however, I get the following behaviours:

HTTP ERROR 500 javax.servlet.ServletException: Failed to extract the Entity Action from URL [http://cms.example.com/xwiki/wiki]
URI:	/xwiki/wiki
STATUS:	500
MESSAGE:	javax.servlet.ServletException: Failed to extract the Entity Action from URL [http://cms.example.com/xwiki/wiki]
SERVLET:	action
CAUSED BY:	javax.servlet.ServletException: Failed to extract the Entity Action from URL [http://cms.example.com/xwiki/wiki]
CAUSED BY:	java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0

Any sense of what I’m doing wrong? This same approach has gone just fine for other sites and services that I run locally on their own VMs.

Thanks for any help you can offer.

You may want to take a look at https://www.xwiki.org/xwiki/bin/view/Documentation/AdminGuide/Installation/ApacheHTTPD/.

Thanks, Thomas. I feel like I’m getting closer, but something’s still amiss.

What happens now is:

  • http://cms.example.com: Empty response
  • https://cms.example.com: Empty response, but redirects to http://cms.example.com/xwiki/bin/view/Main/
  • https://cms.example.com/xwiki/bin/view/Main/: Works properly

The proxy VM’s apache config is now what you linked to verbatim (with appropriate values substituted). I’ve tried various configs of the actual host machine but continue to get the same behaviour. I checked xwiki.cfg to see if it was forcing https, but that setting is not set. I’m not sure what I’m missing.

That’s strange. What’s indicated on the page I linked is supposed to produce: http://cms.example.com redirect to https://cms.example.com which redirect to https://cms.example.com/xwiki/.

Not sure I understand why this is a problem. That’s usually how the proxy in front of XWiki is configured.

I guess I wasn’t entirely clear. The URL gets rewritten as described, but the page doesn’t load. It’s an empty response.

The whole thing is rather strange. I can’t see any good reason for the behavior I’m seeing.

I figured it out. The redirect sends traffic to /xwiki/ but the ProxyPass location and URL are /xwiki. As long as the redirect and the ProxyPass match, it works.

2 Likes