# Apache 2 - Setup Reverse Proxy to Access Private Network Over The Internet

Do you already have apache2 configured on your server, and you want to have another application running on the same port as apache have? which is port 80.

We can do it by implementing reverse proxy, so how to do it?

### 1\. Create Virtual Host

We need to create a virtual host, in this case I will try to create magento245.dev.fiko.me

```apache
<VirtualHost *:80>
    ServerAdmin hi@fiko.me
    ServerName testing.dev.fiko.me
</VirtualHost>
```

### 2\. Setup Reverse Proxy

Next we need to place reverse proxy, and point this virtual host to original port you have previously installed on. In this case I already installed my application locally on port of 8082, so I need to point to port of 8082.

```apache
<VirtualHost *:80>
    ServerAdmin hi@fiko.me
    ServerName testing.dev.fiko.me

    SSLProxyEngine On
    RequestHeader set Front-End-Https "On"
    ProxyPreserveHost On
    SSLProxyVerify none
    SSLProxyCheckPeerCN off
    SSLProxyCheckPeerName off
    SSLProxyCheckPeerExpire off

    ProxyPass / http://127.0.0.1:8082/
    ProxyPassReverse / http://127.0.0.1:8082/
</VirtualHost>
```

### 3\. Try to test your apache2 configuration

Try to run :

```bash
sudo apache2ctl configtest
```

it should have `Syntax Ok` response.

Once it's good, restart your apache

```bash
sudo service apache2 restart
```

and try to access your application from browser.

### 4\. Install Required Modules (Optional)

Do you face this error?

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1681106201699/9595c644-2c92-422c-a3c1-d114fde62dcb.png align="center")

It's too general, but maybe you haven't enabled required apache2 modules, you need to enable these modules:

```bash
sudo a2enmod ssl
sudo a2enmod proxy
sudo a2enmod proxy_balancer
sudo a2enmod proxy_http
```

Then restart your apache2, and refresh the browser.

---

References:

* [https://www.cloudflare.com/en-gb/learning/cdn/glossary/reverse-proxy/](https://s.id/1FxP5)
    
* [https://stackoverflow.com/questions/23931987/apache-proxy-no-protocol-handler-was-valid](https://s.id/1FxPe)
    
* [https://community.bitwarden.com/t/linux-installation-with-existing-apache-server/39506/4](https://s.id/1FxPn)
