How to set up proxy in .htaccess

后端 未结 1 1525
野趣味
野趣味 2020-12-09 17:48

The Apache documentation states that RewriteRule and the should be put in the server configuration, but they can be put in htaccess because of shared hosting situations. I a

相关标签:
1条回答
  • 2020-12-09 17:56

    Unfortunately, I'm fairly sure what you want to do isn't possible: I'm trying to do the exact same thing! From my research, I'm fairly confident it's not possible.

    Put simply, you need to use ProxyPassReverse, which is only available at a VirtualHost level (or similar); not a htaccess level.

    Edit: the only way I have achieved this is by also configuring the responding server/application to know it's behind a proxy, and serving pages appropriately. That is, I use .htaccess to redirect to another server as follows:

      RewriteEngine on
      RewriteRule  (.*)  http://localhost:8080/$1  [P,L] 
    

    Then on the application server -- in this case, a JIRA installation -- I configured the Java Tomcat/Catalina appropriately to serve pages with the proxied information:

     proxyName="my.public.address.com"
     proxyPort="80"
    

    However, that's not completely transparent; the app server needs to serve pages in a proxied manner. It might be of some use, though.

    0 讨论(0)
提交回复
热议问题