Giter Site home page Giter Site logo

nginx-template-image's Introduction

nginx-template-image

This container allows you to use the environment variables set by a Docker link inside of your nginx configuration.

Usage

Mount your configuration to /etc/nginx/sites-templates, preferably read-only. To capture logs, mount a writable directory to /var/log/nginx.

Both HTTP (80) and HTTPS (443) ports are exposed.

For example:

docker run \
  --publish 8080:80 \
  --publish 8443:443 \
  --volume /tmp/nginx-config:/etc/nginx/sites-templates:ro \
  --volume /tmp/nginx-logs:/var/log/nginx \
  --link my-rails-app:rails \
  shepmaster/nginx-template-image

Example nginx config

This is just an example of how to use the templating with a linked container named rails, and should not be treated as an nginx configuration guide!

server {
  listen       80;
  server_name  my-cool-app.dev;

  location / {
    if (!-f $request_filename) {
      proxy_pass   http://${RAILS_PORT_3000_TCP_ADDR}:${RAILS_PORT_3000_TCP_PORT};
      break;
    }
  }
}

Further information

Environment variables

Docker links are communicated via environment variables, but nginx does not easily allow environment variables in configuration files.

To work around this, configuration files mounted at /etc/nginx/sites-templates will be copied to /etc/nginx/sites-enabled. Any file that ends with .tmpl will have variable references like ${FOO} replaced with the corresponding environment variable and have the .tmpl suffix removed.

Only include .conf files

The default nginx configuration includes all files in sites-enabled, which makes it difficult to have supplemental files like SSL keys in the same directory. This container will only load files that end in .conf.

nginx-template-image's People

Contributors

shepmaster avatar andystanton avatar clkao avatar themouette avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.