Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to set up a reverse proxy for Recaptcha on Apache
LoadModule ssl_module modules/mod_ssl.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule filter_module modules/mod_filter.so
LoadModule substitute_module modules/mod_substitute.so
<VirtualHost *:443>
ServerName yourdomain.com:443
SSLEngine On
SSLProxyEngine On
SSLProtocol all -SSLv2
SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5:!SEED:!IDEA
SSLCertificateFile cert.pem
SSLCertificateKeyFile key.pem
SSLCertificateChainFile chain.pem
ProxyVia On
ProxyRequests Off
ProxyPass "/recaptcha" "https://www.google.com/recaptcha"
ProxyPassReverse "/recaptcha" "https://www.google.com/recaptcha"
AddOutputFilterByType SUBSTITUTE text/html text/css text/javascript application/javascript
Substitute "s/www.google.com/yourdomain.com/ni"
Substitute "s/www.gstatic.com/static.yourdomain.com/ni"
ProxyPassReverseCookieDomain "www.google.com" "yourdomain.com"
ProxyPassReverseCookieDomain "www.gstatic.com" "static.yourdomain.com"
</VirtualHost>
<VirtualHost *:443>
ServerName static.yourdomain.com:443
SSLEngine On
SSLProxyEngine On
SSLProtocol all -SSLv2
SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5:!SEED:!IDEA
SSLCertificateFile cert.pem
SSLCertificateKeyFile key.pem
SSLCertificateChainFile chain.pem
ProxyVia On
ProxyRequests Off
ProxyPass "/" "https://www.gstatic.com/"
ProxyPassReverse "/" "https://www.gstatic.com/"
AddOutputFilterByType SUBSTITUTE text/html text/css text/javascript application/javascript
Substitute "s/www.google.com/yourdomain.com/ni"
Substitute "s/www.gstatic.com/static.yourdomain.com/ni"
ProxyPassReverseCookieDomain "www.google.com" "yourdomain.com"
ProxyPassReverseCookieDomain "www.gstatic.com" "static.yourdomain.com"
</VirtualHost>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment