Apache Reverse Proxy with SSL and WebSockets on RHEL/CentOS: Full Configuration

Here’s the configuration I use to run Apache httpd as a reverse proxy in front of a back-end service, with SSL termination and WebSocket support, on a Red Hat-family server.

1. Load the Proxy Modules

Edit the proxy module config:

vi /etc/httpd/conf.modules.d/00-proxy.conf

Make sure these modules are loaded:

# Load necessary modules
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule ssl_module modules/mod_ssl.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so

# Load lbmethod modules
LoadModule lbmethod_bybusyness_module modules/mod_lbmethod_bybusyness.so
LoadModule lbmethod_byrequests_module modules/mod_lbmethod_byrequests.so
LoadModule lbmethod_bytraffic_module modules/mod_lbmethod_bytraffic.so
LoadModule lbmethod_heartbeat_module modules/mod_lbmethod_heartbeat.so

# Load additional proxy modules
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_express_module modules/mod_proxy_express.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
LoadModule proxy_fdpass_module modules/mod_proxy_fdpass.so
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
LoadModule proxy_hcheck_module modules/mod_proxy_hcheck.so
LoadModule proxy_scgi_module modules/mod_proxy_scgi.so
LoadModule proxy_uwsgi_module modules/mod_proxy_uwsgi.so

2. Create the Site’s VirtualHost

Edit your site’s config file:

vi /etc/httpd/sites-enabled/service.domainname.com.conf

Replace the host name, certificate paths, and backendserverIP:portnumber with your own values. The rewrite rules send WebSocket upgrade requests to the back end over ws://; everything else goes through ProxyPass.

<VirtualHost *:443>
ServerName service.domainname.com

SSLEngine on
SSLCertificateFile /etc/pki/tls/certs/yourcert.crt
SSLCertificateKeyFile /etc/pki/tls/private/yourprivatekey_privatekey.key
SSLCertificateChainFile /etc/pki/tls/certs/bundle.crt

RewriteEngine on
RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteCond %{HTTP:Connection} upgrade [NC]
RewriteRule /(.*) "ws://backendserverIP:portnumber/$1" [P,L]

ProxyPreserveHost On
ProxyPass / http://backendserverIP:portnumber/
ProxyPassReverse / http://backendserverIP:portnumber/

ErrorLog /var/log/httpd/service.domainname.com/error.log
CustomLog /var/log/httpd/service.domainname.com/access.log combined
</VirtualHost>

3. Restart Apache

Restart httpd and test your new site. Related: Apache security headers for an A+ rating.

Vulnerability in SSL 3.0 Could Allow Information Disclosure: Disable It with Group Policy or IE Settings

A vulnerability in SSL 3.0 could allow information disclosure. The fix is to turn off SSL 3.0 and use TLS instead. Here are two ways to do that on Windows clients: centrally with Group Policy, or per machine in Internet Explorer. To disable SSL 3.0 on the server side, see how to disable SSL 3.0 on Microsoft IIS.

Option 1: Disable SSL 3.0 with Group Policy

Use the Turn off Encryption Support setting to disable SSL 3.0 and enable TLS 1.0, TLS 1.1 and TLS 1.2 across the domain.

  1. Open Group Policy Management.
  2. Right-click the Group Policy Object to modify and select Edit.
  3. In the Group Policy Management Editor, browse to Computer Configuration > Administrative Templates > Windows Components > Internet Explorer > Internet Explorer Control Panel > Advanced Page > Turn off Encryption Support.
  4. Double-click Turn off Encryption Support and click Enabled.
  5. In the Options pane, set Secure Protocol combinations to Use TLS 1.0, TLS 1.1, and TLS 1.2.
  6. Click OK.

Option 2: Disable SSL 3.0 in Internet Explorer

To change the protocol versions Internet Explorer uses for HTTPS on a single computer:

  1. On the Internet Explorer Tools menu, click Internet Options.
  2. Click the Advanced tab.
  3. In the Security category, uncheck Use SSL 3.0 and check Use TLS 1.0, Use TLS 1.1 and Use TLS 1.2 (if available).
  4. Click OK, then exit and restart Internet Explorer.

Want to check whether a server still accepts SSLv3? Here’s a quick way to test for SSLv3.