Created
September 9, 2016 20:54
-
-
Save andyshinn/3511fbd091dc87ad78771e380fb527d4 to your computer and use it in GitHub Desktop.
Mimicking CORS preflight responses in Apache
This file contains hidden or 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
<VirtualHost _default_:443> | |
ServerName yourhost | |
ServerAdmin [email protected] | |
SSLEngine on | |
SSLCertificateFile /etc/ssl/private/yourorg.com.crt | |
SSLCertificateKeyFile /etc/ssl/private/yourorg.com.key | |
SSLCertificateChainFile /etc/ssl/private/chain.pem | |
SSLProxyEngine On | |
ProxyRequests Off | |
ProxyPreserveHost On | |
RewriteEngine On | |
RewriteCond %{REQUEST_METHOD} OPTIONS | |
RewriteRule ^(.*)$ - [ENV=PREFLIGHT:true] | |
SetEnvIf Origin "^(.*)$" ORIGIN=$0 | |
Header always set Access-Control-Allow-Origin %{ORIGIN}e env=PREFLIGHT | |
Header always set Access-Control-Allow-Credentials "true" env=PREFLIGHT | |
Header always set Access-Control-Allow-Methods "POST, GET, OPTIONS" env=PREFLIGHT | |
RewriteCond %{REQUEST_METHOD} OPTIONS | |
RewriteRule ^(.*)$ $1 [R=204,L] | |
ProxyPass / http://host.yourorg.com:8087/ | |
ProxyPassReverse / http://host.yourorg.com:8087/ | |
</VirtualHost> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
works well on 2.4, thanks for this gist :)