Skip to content

danfinnie/reverse_proxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Reverse Proxy

Builds a Docker image that starts an nginx reverse proxy for other docker containers. The intended use case is if you have a few containers running on different ports and want to do name-based virtual hosting on them.

Example With Fig

A sample fig.yml file:

app1:
  build: 'git://github.com/danfinnie/app1.git'
app2:
  build: 'git://github.com/danfinnie/app2.git'
reverseproxy:
  build: 'git://github.com/danfinnie/reverse_proxy.git'
  links:
    - "app1"
    - "app2"
  ports:
    - "80:80"
  environment:
    PROXIED_HOSTNAME: 'example.com'
    APP_PROXIES: 
      - [app1, 4000] # app1 exposes port 4000
      - [app2, 3000] # app2 exposes port 3000

Now, run fig up to build all of the Docker containers and start the servers. Now, app1.example.com is proxied to an app1 Docker container on port 3000 and app2.example.com to an app2 Docker container on port 4000. The PROXIED_HOSTNAME variable should be set to the output of the hostname command, it needs to be injected from the fig.yml file because the image does not know the hostname of it's parent.

Whichever container is defined first in the APP_PROXIES variable is the default, so if you want something at your root domain, just list it first.

If you're playing with your configuration file and want to start your fig images from scratch, give this a whirl:

fig kill && fig rm --force && fig build reverseproxy && fig up

About

Nginx reverse proxy for Docker containers

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors