I've never set up a proxy before. I'm using shared hosting, so to set Apache directives, I need to use .htaccess. Can I use .htaccess to do something like below? Any limitations?
ProxyRequests Off
ProxyPass /img/ http://internal.example.com/img/
ProxyPass /app/ http://internal.example.com/app/
ProxyPassReverse / http://internal.example.com/
You cannot use a
ProxyPass
in an htaccess file. The documentation says it is only applicable in the context:which excludes htaccess (you can't have a
<Directory>
block in htaccess). However, you can use aProxyPassReverse
to internally rewrite the Location field of proxied requests that cause a redirect. You'll just need to use mod_rewrite'sP
flag to proxy instead ofProxyPass
. So something like:Just to be clear, you cannot use
ProxyPass
orProxyPassReverse
in the htaccess file, but you can useProxyPassReverse
with mod_rewrite rules that utilize theP
flag.