Last active
March 25, 2020 04:24
-
-
Save kevbradwick/5c9667d03332847a9cfa71829a76b687 to your computer and use it in GitHub Desktop.
Reverse proxy to host using Docker
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
upstream api-app { | |
server host.docker.internal:8000; | |
} | |
server { | |
listen 80; | |
listen [::]:80; | |
server_name api-app.localhost; | |
location / { | |
proxy_pass http://api-app; | |
proxy_redirect off; | |
proxy_set_header Host $host; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-Forwarded-Host $server_name; | |
} | |
} |
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" | |
services: | |
# nginx reverse proxy to enable the api and front end to be served from the | |
# same host:port. | |
# http://api-app.localhost:5000 -> dockerhost:8000 | |
# http://web-app.localhost:5000 -> dockerhost:8080 | |
proxy: | |
image: nginx:alpine | |
ports: | |
- "5000:80" | |
volumes: | |
- "./docker/web.conf:/etc/nginx/conf.d/web.conf:ro" | |
- "./docker/api.conf:/etc/nginx/conf.d/api.conf:ro" |
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
upstream web-app { | |
server host.docker.internal:8080; | |
} | |
server { | |
listen 80; | |
listen [::]:80; | |
server_name web-app.localhost; | |
location / { | |
proxy_pass http://web-app; | |
proxy_http_version 1.1; | |
proxy_redirect off; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection "Upgrade"; | |
proxy_set_header Host $host; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-Forwarded-Host $server_name; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment