Last active
August 26, 2024 16:50
-
-
Save zypA13510/fc3669a4c6957f3593c6ebed76d1d433 to your computer and use it in GitHub Desktop.
How to set up a reverse proxy for Recaptcha on Apache httpd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
Additionally, since recaptcha load script with intergity check, we need to disable intergrity check with extra substitue like this.
Substitute "s/po.integrity/po.integrit1/ni"
So, broswer will load script without intergrity check.
please where to add this file?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
RequestHeader unset Accept-Encoding
Unset Accept-Encoding is required for Substitute module to work properly to replace strings.