Skip to content

Instantly share code, notes, and snippets.

@anand-kashyap
Last active February 10, 2021 10:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anand-kashyap/640527198d2a61a333b2e686d5258ce5 to your computer and use it in GitHub Desktop.
Save anand-kashyap/640527198d2a61a333b2e686d5258ce5 to your computer and use it in GitHub Desktop.
nginx as docker container
// use docker compose for running server and passing env files
// create a network before running nginx container
docker network create --driver bridge reverse-proxy
// then run nginx container
docker run -d -p 80:80 -p 443:443 \
--name nginx-proxy \
--net reverse-proxy \
-v $HOME/certs:/etc/nginx/certs:ro \
-v /etc/nginx/vhost.d \
-v /usr/share/nginx/html \
-v /var/run/docker.sock:/tmp/docker.sock:ro \
--label com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy=true \
jwilder/nginx-proxy
// Run the Let's Encrypt helper container.
docker run -d \
--name nginx-letsencrypt \
--net reverse-proxy \
--volumes-from nginx-proxy \
-v $HOME/certs:/etc/nginx/certs:rw \
-v /var/run/docker.sock:/var/run/docker.sock:ro \
jrcs/letsencrypt-nginx-proxy-companion
// add the network in any new docker compose file
networks:
default:
external:
name: reverse-proxy
// run docker-compose up -d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment