vHost Apache2 domain reflect to port

Mario tsai
1 min readOct 9, 2023

Reverse Proxy /admin for employee user, / for customer user

Environment: Ubuntu 20

reference:

Assume you know Apache2 in ubuntu~!

What My boss want is http(s)://domain.com -> frontEnd service(web), http(s)://domain.com/admin -> backStage service(web)

One domain call: yourDomain

ip call: yourIp

frontEnnd Port: frontEndPort

backStage Port: backendPort

In Ubuntu, open terminal and

sudo vim /etc/apache2/sites-available/000-default.conf

And

Type like below

<VirtualHost *:80>
ServerName yourDomain
ServerAlias www.yourDomain
ProxyRequests off
<Proxy *>
Order allow,deny
Allow from all
</Proxy>


ProxyPass /admin http://yourIp:backendPort/
ProxyPassReverse /admin yourIp:backendPort/
ProxyPass / http://yourIp:frontEndPort/
ProxyPassReverse / http://yourIp:frontEndPort/
ProxyPreserveHost on

</VirtualHost>

restart apache, it’s done.

--

--

Mario tsai

Major in physical education. Football referee. And high interest in looking the world through the numbers.