Reverse proxy for local development with Docker or Podman
Explore the docs »
Report Bug
·
Request Feature
Table of Contents
To use this project you need to have Docker or Podman installed. No other dependencies are required.
You can download the script and run it from there. Alternatively you can clone the repository and run the script from there
curl -O https://raw.githubusercontent.com/dontfreakout/dev-proxy/master/start-proxy.sh
chmod +x start-proxy.sh
for example:
mv start-proxy.sh ~/.local/bin/dev-proxy
You have to configure the containers you want to proxy in the docker-compose.yml
file.
You need to add the hostname, port and protocol to the environment variables of the container.
Also, you need to add the container and the service to the proxy network.
Example configuration:
services:
my-service:
networks:
proxy:
environment:
VIRTUAL_HOST: example.localhost
VIRTUAL_PORT: 80 # port of the service
VIRTUAL_PROTO: http # (valid options are https or http) if using https, you probably want to use VIRTUAL_PORT: 443
networks:
proxy:
name: proxy_network # name of the proxy network needs to be the same as in the script
If you want to use multiple domains on one service you can separate them with a comma.
VIRTUAL_HOST: example.localhost,example2.localhost
You can run the script using the following command. This will download docker image and start the proxy with default settings.
./start-proxy.sh
Usage: ./start-proxy.sh [options] [command]
Command | Description |
---|---|
list |
List currently available vhost urls |
stop |
Stop the proxy |
update |
Update proxy container |
uninstall |
Remove the proxy container and network |
The proxy is by default available to local machine on port 80 and 443. You can change this with parameters.
./start-proxy.sh -s 8443 -i 8080
Option | Description | Default value |
---|---|---|
-s , --secure |
Port for https | 443 for docker, 8443 for rootless podman |
-i , --insecure |
Port for http | 80 for docker, 8080 for rootless podman |
-n , --network |
Name of the proxy network | proxy_network |
-c , --container |
Name of the proxy container | dev-proxy |
-h , --help |
Show help | |
-v , --version |
Show version |
The proxy uses a self-signed certificate. To add it to your browser and get rid of the warning you need to import the root certificate. You can follow the steps below to import the certificate.
- Open Chrome and go to
chrome://settings/certificates
- Click on
Authorities
tab - Click on
Import
- Select Root certificate from config folder
- Linux:
~/.config/dev-proxy/certs/rootCA.crt
- MacOS:
~/Library/Application Support/dev-proxy/certs/rootCA.crt
or~/.config/dev-proxy/certs/rootCA.crt
- Linux:
- Click on
Trust this certificate for identifying websites
- Click on
OK
- Open Firefox and go to
about:preferences#privacy
- Scroll down and click on
View Certificates
- Click on
Authorities
- Click on
Import
- Select Root certificate from config folder
- Linux:
~/.config/dev-proxy/certs/rootCA.crt
- MacOS:
~/Library/Application Support/dev-proxy/certs/rootCA.crt
or~/.config/dev-proxy/certs/rootCA.crt
- Linux:
- Click on
OK
- add option to install as docker service
- possibility to install certificate system-wide
- check for new version and self update
See the open issues for a list of proposed features (and known issues).
See CHANGELOG.md for more information on what has changed recently.
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
Distributed under the MIT License. See LICENSE
for more information.