Example
services:
foocontainer:
# Your container here listening, for example,
# on port 5000.
# No label, no port to bind...
proxy:
# Pathwae!
image: quay.io/pathwae/proxy
ports:
- "80:80"
- "443:443"
- "8080:8080"
environment:
CONFIG: |
foo.bar.localhost:
# foocontainer port 5000
to: http://foocontainer:5000
force_ssl: true
- Use
docker-compose up
or podman-compose up
- And navigate to
http://foo.bar.localhost
-
force_ssl
will automatically redirect the browser to https
.
No label, no arguments, no configuration file.
Everything is declared on the proxy container environment. This is the "standard" for containers.
You also don't need to use depends_on
because the proxy doesn't need to wait for backends containers.
The port 8080
provides a simple monitor view of the backend.
What about "rootless" containers?
You're using Podman
? - Good news, that works! Pathwae does not use Docker API, you don't need to mount the socket file, everthing is controlled by the environment.
You only need to allow your standard user to open 80/443
ports with this command:
That's simple:
sudo sysctl -w net.ipv4.ip_unprivileged_port_start=0
Make it permanent if you want:
sudo mkdir -p /etc/sysctl.d
echo "net.ipv4.ip_unprivileged_port_start=0" | \
sudo tee /etc/sysctl.d/99-unprivileged_port.conf
But I like configuration files!
OK, no problem, you can create the confiuration file:
foo.bar.localhost:
to: http://foocontainer:5000
force_ssl: true
Then mount the file in Pathwae container, and indicate the configuration file path with CONFIG_FILE
environment variable.
services:
proxy:
image: quay.io/pathwae/proxy
ports:
- "80:80"
- "443:443"
- "8080:8080"
environment:
- CONFIG_FILE: /config/config.yaml
volumes:
- ./config.yaml:/config/config.yaml:ro,z
Need a "near the reality" domain name?
One solution (Docker only for the moment):
- set a
hostname
on the pathwae container - and use Docker-Domains daemon to have local domains.
Docker-Domains is a nice daemon that allows you to use whatever the domain you want, even .com
domains!
It will also remove the need to bind ports 80, 443 and 8080 to localhost.