Skip to main content

Proxy

Overview​

The Proxy is a component that allows you to intercept and modify requests and responses. It comes to solve the multi projects communication problem by providing a way to redirect requests to the correct project.

This is actually a simple Apache server that is configured to act as a proxy.

Usage​

Assume that you have two projects running on your machine. As you can't have two projects running on the same port, you need to use the proxy to redirect the requests to the correct project.

Note that before starting the proxy, you need to configure your projects to listen on different ports than the 80 and the 443.

Create a configuration file​

./httpd-vhosts.conf
<VirtualHost *:80>
ServerName my_app.dev.local
ProxyPreserveHost On
ProxyRequests On
ProxyPass / http://host.docker.internal:8081/
ProxyPassReverse / http://host.docker.internal:8081/
ProxyTimeout 300
</VirtualHost>

<VirtualHost *:80>
ServerName my_api.dev.local
ProxyPreserveHost On
ProxyRequests On
ProxyPass / http://host.docker.internal:8082/
ProxyPassReverse / http://host.docker.internal:8082/
ProxyTimeout 300
</VirtualHost>

Start​

dcmd proxy start ./httpd-vhosts.conf

Stop​

dcmd proxy stop

Update​

dcmd proxy update