Configuring reverse proxy with mod_proxy rules using only .htaccess file
After some discussion with the hosting provider and further research into the issue I've concluded it cannot be done, due to the host restrictions.
The apache documentation itself specifies that ProxyPass
can only be used in the Context: server config, virtual host, directory
Here is a link to some useful information which might help others Can ProxyPass and ProxyPassReverse work in htaccess
Related videos on Youtube
![crbon](https://i.stack.imgur.com/E7iZF.jpg?s=256&g=1)
Comments
-
crbon over 1 year
I am trying to connect website (which is share hosted) to a remote server, so that when I access
http://example.com/test/
it will display the results fromhttp://remote-example.com/
(which is a web app server)The web hosting provider only allows me to modify the
.htaccess
file for configuration, they said mod_proxy is enabled and it can be configured with the.htaccess
file.They linked me Apache's Documentation, but I haven't been able to get it to work. The hosting provider is using Lightspeed as the web server.
Is someone able to give me an example of what the
.htaccess
file should look like?Can a reverse proxy be configured by modifying the
.htaccess
file only?-
crbon over 6 years@MrWhite I've tried using
ProxyPass /test http://remote-example.com
andProxyReverse /test http://remote-example.com
But it didn't make any difference. Maybe theproxy_http
module is not enabled -
reinierpost over 4 years
-
-
DocRoot over 6 yearsDid you try using mod_rewrite's
RewriteRule
with theP
flag? This allows mod_rewrite to route requests through mod_proxy and is the only way you'd be able to do this in a shared environment, without access to the server - which appears to be what your host is suggesting. (Then again, this still might not be sufficient. Then again, if it's not then why has your host enabled mod_proxy in the first place?) -
crbon over 6 years@DocRoot they have rewrite and mod_proxy enabled but its still cannot be done under their current system
-
reinierpost over 4 years
RewriteRule [P]
corresponds toProxyPass
, but it doesn't implementProxyPassReverse
. I'm not sure it is possible to implement its behavior in.htaccess
- you need to rewrite theLocation
response header.