Reverse proxy NGINX Docker container to localhost
1 min readApr 19, 2018
So how do you route reverse proxy and NGINX container traffic to your local machine?
This setup is based on Docker Compose so let’s first setup our docker compose file config.
version: '3'
services:
nginx:
image: nginx
ports:
- "80:80"
volumes:
- ./dev-env/nginx/dev.conf:/etc/nginx/conf.d/default.conf
And now, let’s take a look at our NGINX configuration
server {
listen 80;
location / {
proxy_pass http://host.docker.internal:4200;
}
}
By using the hostname `host.docker.internal`, Docker will resolve it our localhost’s IP and NGINX will route traffic to it.