Skip to content

Instantly share code, notes, and snippets.

@rafaelfoster
Last active February 15, 2022 20:58
Show Gist options
  • Save rafaelfoster/7249179 to your computer and use it in GitHub Desktop.
Save rafaelfoster/7249179 to your computer and use it in GitHub Desktop.
Apache Reverse Proxy + SSL Client Authentication
# The first two lines are also important
# Some tests with *:443 never work for me. Needed to test more times
NameVirtualHost server.example.com:443
<VirtualHost server.example.com:443>
ServerName server.example.com
# SSL Params
# Activate the client certificate
SSLEngine On
SSLCertificateFile /etc/httpd/cert/ca.crt
SSLCertificateKeyFile /etc/httpd/cert/ca.key
# Proxy Params
ProxyVia On
ProxyRequests On
ProxyPreserveHost Off
SSLProxyVerifyDepth 2
ProxyPass /example http://example.com/
ProxyPassReverse /example http://example.com
Redirect Permanent /example http://example.com
<Location /example>
# SSL Params
# Enable de Client Authentication only in this location
SSLVerifyDepth 3
SSLVerifyClient optional_no_ca
SSLOptions +ExportCertData +StdEnvVars
# Define HTTP Headers that will be forwarded to WebServer
# CLIENT_SSL vars founded on: http://httpd.apache.org/docs/2.2/mod/mod_ssl.html
RequestHeader set SSL_CLIENT_S_DN "%{SSL_CLIENT_S_DN}s"
RequestHeader set SSL_CLIENT_I_DN "%{SSL_CLIENT_I_DN}s"
RequestHeader set SSL_SERVER_S_DN_OU "%{SSL_SERVER_S_DN_OU}s"
RequestHeader set SSL_CLIENT_VERIFY "%{SSL_CLIENT_VERIFY}s"
requestHeader set SSL_CLIENT_S_DN_x509 "%{SSL_CLIENT_S_DN_x509}s"
</Location>
</VirtualHost>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment