Ansible Role for Nginx in Docker

Build Status

Derek Merck
derek_merck@brown.edu
Rhode Island Hospital and Brown University
Providence, RI

Configure and run a Nginx web server with reverse proxying in a Docker container.

Dependencies

Galaxy Roles

Remote Node

Role Variables

Docker Image and Tag

Always uses the official Nginx image.

Set the Nginx version tag.

nginx_docker_image_tag:   "latest"

Docker Container Configuration

Always runs on ports 80 and 443 (if secured)

nginx_container_name:    "nginx"
nginx_config_dir:        "/opt/{{ nginx_container_name }}"

Service Configuration

See examples for format of upstream reverse proxies and security.

nginx_upstreams:         []
nginx_security:          {}

Example Playbook

- hosts: web_server
  roles:
    - role: derekmerck.nginx_docker
      nginx_upstreams:
        - name: upstream
          path: /my_path    # No trailing slash, rewrite host -> host/my_path
          pool:
            - port: 5000
              # host defaults to "localhost"
            - host: another_host
              port: 80
      nginx_security:
        cert_dir:    "/opt/certs"
        common_name: "www.example.com"

License

MIT