I need to setup Apache proxies for multiple servers, one proxy for one server. I can do this in two ways:
Setup one virtual host and multiple proxies. Each server is served as a sub-directory of the virtual host: aaa.bbb.ccc/test1 and aaa.bbb.ccc/test2
<VirtualHost *:443> ServerName aaa.bbb.ccc RewriteEngine on RewriteRule ^/test1$ /test1/ [R] RewriteRule ^/test1(.*) http://localhost:8080$1 [P] RewriteRule ^/test2$ /test2/ [R] RewriteRule ^/test2(.*) http://localhost:8081$1 [P] <Location "/test1"> ... </Location> <Location "/test2"> ... </Location> .... </VirtualHost>
Setup N virtual hosts and N proxies, serving N servers. Each server will be served with one virtual host.
NameVirtualHost *:443 <VirtualHost *.443> ServerName aaa.bbb.ccc RewriteEngine on RewriteRule ^(.*) http://localhost:8080$1 [P] <Location "/"> ... </Location> </VirtualHost> <VirtualHost *.443> ServerName ddd.bbb.ccc RewriteEngine on RewriteRule ^(.*) http://localhost:8081$1 [P] <Location "/"> ... </Location> </VirtualHost>
Both works. However I don't know which one is better. Can someone compare the pros and cons of the two approaches?