Skip to content

Instantly share code, notes, and snippets.

@franzwong
Created January 1, 2019 10:12
Show Gist options
  • Save franzwong/77e9738fc012efb370bddde6ec415f0c to your computer and use it in GitHub Desktop.
Save franzwong/77e9738fc012efb370bddde6ec415f0c to your computer and use it in GitHub Desktop.
Dockerized nginx as reverse proxy
events {}
http {
upstream webapp {
server host.docker.internal:3000; # development only
}
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://webapp;
proxy_set_header X-Forwarded-For $remote_addr; # reset X-Forwarded-For
}
}
}
# map port 8080 (host) to 80 (docker)
docker run \
--name my-nginx \
-v $PWD/nginx.conf:/etc/nginx/nginx.conf:ro \
-d \
--rm \
-p 8080:80 \
nginx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment