More Configurations for the Apache HTTP Proxy Server
Explanation
After Configuring the Apache HTTP Server as a Proxy on a Linux OS or on Windows, you can add several improvements to the configuration. For example, you can enable HTTPS secure connections. To do this, you need to enable the Apache SSL module and use an additional <VirtualHost> on port 443 where you also move the Proxy Rules from <VirtualHost *:80>. Thus, modify and add in the /etc/apache2/sites-available/xwiki.conf file:
<VirtualHost *:443>
ServerName localhost
SSLEngine on
SSLCertificateFile /path/to/certificate
SSLCertificateKeyFile /path/to/privatekey
ProxyRequests Off
ProxyPreserveHost On
RequestHeader set X-Forwarded-Proto "https"
ProxyPass /xwiki http://localhost:8080/xwiki
ProxyPassReverse /xwiki http://localhost:8080/xwiki
</VirtualHost>To redirect HTTP to HTTPS, use a port 80 VirtualHost with Rewrite Rules:
<VirtualHost *:80>
ServerName localhost
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} !^/.well-known
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
</VirtualHost>Make sure you update the XWiki configuration file (xwiki.cfg) with the new URL, (e.g., xwiki.home=https://localhost/xwiki).
After making changes in the configuration file, test and restart Apache.
FAQ
What are some common mistakes?
Pay attention to the followings, as they are most common mistakes:
- Issue: WebSocket not working. Check: proxy_wstunnel is enabled.
- Issue: HTTPS issues. Check: configuration of SSL is correct.