Skip to content

Instantly share code, notes, and snippets.

@bitbay
Created December 23, 2021 10:17
Show Gist options
  • Save bitbay/186de1de08716148a3cadda9ecaa7a36 to your computer and use it in GitHub Desktop.
Save bitbay/186de1de08716148a3cadda9ecaa7a36 to your computer and use it in GitHub Desktop.
Docker compose with minimal nginx reverse-proxy with localhost subdomain
version: '3.9'
services:
nginx:
image: nginx:1.20.2-alpine
ports:
- 80:80
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
depends_on:
- api
- web
api:
image: dannyben/whoami
container_name: api
expose:
- 3000
environment:
MESSAGE: I am api.localhost
web:
image: dannyben/whoami
container_name: web
expose:
- 3000
environment:
MESSAGE: I am the web.localhost
events {
}
http {
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
location / {
proxy_pass http://web:3000;
}
}
server {
listen 80;
listen [::]:80;
server_name api.localhost;
location / {
proxy_pass http://api:3000;
}
}
}
@bitbay
Copy link
Author

bitbay commented Dec 23, 2021

$ docker-compose up -d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment