- Installation
apt install -y apache2
- Configuration on
/etc/apache2/
- Installation
apt install docker
docker run --name apache -d -p 80:80 httpd
- Configuration
docker exec -it apache bash
cd /usr/local/apache2
- Baremetal
cd /etc/apache2/sites-enabled/000-default.conf on Baremetal
- Docker
cd /usr/local/apache2/conf/httpd.conf
Uncomment Include conf/extra/httpd-vhosts.conf
then,
cd /usr/local/apache2/conf/extra/httpd-vhost.conf
- Goal
- Use one IP for multiple domain.
- Another domain except declare domain can't access.
- Can access res/index.html with res.gbesar.com
- Can access res2/index.html with res.bignetlab.my.id
<VirtualHost *:80>
ServerName catchall
<Location />
Require all denied
</Location>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/usr/local/apache2/htdocs/res"
ServerName res.gbesar.com
ServerAlias www.res.gbesar.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/usr/local/apache2/htdocs/res2"
ServerName res.bignetlab.my.id
ServerAlias www.res.bignetlab.my.id
</VirtualHost>
- Reverse Proxy
-
Activate Module
sudo a2enmod proxy sudo a2enmod proxy_http sudo a2enmod proxy_balancer sudo a2enmod proxy lbmethod_byrequest sudo service apache2 restart
-
Activate/Uncomment these 2 module if you run httpd on Docker
nano /usr/local/apache2/conf/httpd.conf
LoadModule proxy_module modules/mod_proxy.so LoadModule proxy_http_module modules/mod_proxy_http.so
-
Define on VHost Configuration
ProxyPass / http://<ip_server>:<port>/ ProxyPassReverse / http://<ip_server>:<port>/
-
Final Block Configuration
- Goals:
- Access
/hello
to access172.17.0.4
content - Access
/
to access content on/usr/local/apache2/htdocs/res2
- Access
<VirtualHost *:80> DocumentRoot "/usr/local/apache2/htdocs/res2" ServerName res.bignetlab.my.id ServerAlias www.res.bignetlab.my.id ProxyPass /hello http://172.17.0.4 ProxyPassReverse /hello http://172.17.0.4 </VirtualHost>
- Goals:
-
Click Here!