Created
December 23, 2021 10:17
-
-
Save bitbay/186de1de08716148a3cadda9ecaa7a36 to your computer and use it in GitHub Desktop.
Docker compose with minimal nginx reverse-proxy with localhost subdomain
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$ docker-compose up -d