Map virtual directory to another web server in apache

Can I configure an Apache web server to map a directory to a path on another web server? For example, can I make requests for http: // server1 / resource / return http: // server2 / resource / . If possible, how do I configure this?

+4
source share
3 answers

mod_proxy is the way to go:

http://httpd.apache.org/docs/2.0/mod/mod_proxy.html 

Using:

 <Location /resource/> ProxyPass http://server2/resource/ SetEnv force-proxy-request-1.0 1 SetEnv proxy-nokeepalive 1 </Location> 
+5
source

mod_rewrite is pretty strong for this. You must set the rewrite rule for / resource / and use 302 redirection to send people to the second server.

http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html

http://www.modrewrite.com/

Unconfirmed example:

 <location "/"> RewriteEngine On RewriteRule ^/resource/(.*)$ http://server2/resource/$1 [R] </location> 
+2
source

I think this question is for serverfault.com. I will not dwell on this in detail, but you can set it using the RewriteCond, RewriteRule directives in the apache configuration.

I used both mod_proxy and mod_rewrite rules to achieve a similar effect. PS: check serverfault.com and ask sysadmin to try.

0
source

Source: https://habr.com/ru/post/1286120/


All Articles