Web applications on the local host in different ports accessed through port 80

On my laptop with Apache

I have different web applications in different directories on my laptop, and I can start using simple web servers listening on different ports. for instance

~/app1/./app.pl
>> listening on http://localhost:3000/

~/app2/./app.pl
>> listening on http://localhost:3001/

~/app3/./app.pl
>> listening on http://localhost:3001/

I want to access the above from my browser like this:

http://localhost/app1
http://localhost/app2
http://localhost/app3

Can I do this with mod_proxy? If so, how?

Update: I have to add that I have Googled for mod_proxy, read tutes on the Apache website and experiment with the following

uncommented the following in my httpd.conf

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_http_module modules/mod_proxy_http.so

added the following to his httpd.conf

<IfModule mod_proxy.c>
    ProxyRequests On
    ProxyPass /app1 http://localhost:3000/
    ProxyPassReverse /app1 http://localhost:3000/
    ProxyPass /app2 http://localhost:3001/
    ProxyPassReverse /app2 http://localhost:3001/
    ProxyPass /app3 http://localhost:3002/
    ProxyPassReverse /app3 http://localhost:3002/
</IfModule>

However, I get HTTP 404 when I try to access the above applications.

+3
2

mod_rewrite mod_proxy. ( VirtualHost):

RewriteEngine On
RewriteRule ^/app1(.*)$ http://localhost:3000/$1 [P]
RewriteRule ^/app2(.*)$ http://localhost:3001/$1 [P]
RewriteRule ^/app3(.*)$ http://localhost:3002/$1 [P]

mod_rewrite [P] -. , mod_proxy, mod_proxy_http mod_rewrite apache, /:

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule rewrite_module modules/mod_rewrite.so
+2

, . Googling "mod_proxy tutorial" ...

, mod_proxy_ajp, AJP. (, Tomcat.)

0

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


All Articles