Skip to content

Automated nginx proxy for Docker containers using docker-gen

License

Notifications You must be signed in to change notification settings

cybercode/nginx-proxy

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nginx-proxy sets up a container which invokes docker-gen on startup, generating a reverse proxy configs for nginx and runs nginx.

Note: Unlike jwilder/ngnix-proxy, it does not run docker-gen as a service or reload nginx

See Automated Nginx Reverse Proxy for Docker for why you might want to use this.

Usage

To run it:

  1. Start any containers you want proxied with an env var VIRTUAL_HOST=subdomain.youdomain.com

     $ docker run -e VIRTUAL_HOST=foo.bar.com  ...
    
  2. Start the proxy

     $ docker run -d -p 80:80 -v /var/run/docker.sock:/tmp/docker.sock:ro jwilder/nginx-proxy
    

The containers being proxied must expose the port to be proxied, either by using the EXPOSE directive in their Dockerfile or by using the --expose flag to docker run or docker create.

Provided your DNS is setup to forward foo.bar.com to the a host running nginx-proxy, the request will be routed to a container with the VIRTUAL_HOST env var set.

Multiple Ports

If your container exposes multiple ports, nginx-proxy will default to the service running on port 80. If you need to specify a different port, you can set a VIRTUAL_PORT env var to select a different one. If your container only exposes one port and it has a VIRTUAL_HOST env var set, that port will be selected.

About

Automated nginx proxy for Docker containers using docker-gen

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Dockerfile 54.0%
  • Shell 33.8%
  • Makefile 12.2%