apache mod_proxy, configuring ProxyPass & ProxyPassReverse for cross-domain ajax calls
I found a working solution:
Enable:
LoadModule proxy_module modules/mod_proxy.soLoadModule proxy_http_module modules/mod_proxy_http.so
Put this in the main section of your configuration (or desired virtual host, if using Apache virtual hosts):
ProxyRequests OffProxyPreserveHost On<Proxy *> Order deny,allow Allow from all</Proxy>ProxyPass /EMBackend http://localhost:8080/backend/mvcProxyPassReverse /EMBackend http://localhost:8080/backend/mvc<Location /EMBackend> Order allow,deny Allow from all</Location>
So I guess I can't put it in .htaccess
or I had to set ProxyPreserveHost On
. I put Include conf/extra/
in the httpd.conf
file and created the httpd-proxy.conf
file and put the script above in it. Restarted apache and it's working!
You could simply add the given lines in the httpd.conf after enabling the proxy modules.
ProxyPreserveHost OnProxyPass /EMBackend http://localhost:8080/backend/mvcProxyPassReverse /EMBackend http://localhost:8080/backend/mvc
Just restart the server and you are done.
In very modern apache, turn on proxy by:
a2enmod proxy;a2enmod proxy_http