lexa-uw.nginx-in-docker

Ansible Role for Setting Up and Running Nginx Server in Docker Container

This role helps you install the Nginx server on your Docker node. It also sets up SSL/TLS for a top "A+" rating on Qualys SSL Labs by default.

Requirements

You need Ansible version 2.5 or higher to use this role.

Role Variables

Package Options:

nginx_global_config Template for the main configuration file.

nginx_allow List of IP addresses that are allowed to access the server.

nginx_dir Base directory for Nginx. (default: /tmp/nginx)

nginx_htpasswd List of users and passwords for basic authentication.

nginx_openssl_dhparam_numbits Number of bits to generate the dhparam certificate. (default: 4096)

Container Options

Settings for running the Docker container. Default values:

nginx_container_command: []
nginx_container_env: {}
nginx_container_image: "nginx:alpine"
nginx_container_log_driver: "json-file"
nginx_container_name: "nginx"
nginx_container_network_mode: bridge
nginx_container_networks: []
nginx_container_pull: "yes"
nginx_container_recreate: "no"
nginx_container_restart_policy: "always"
nginx_container_restart: "no"
nginx_container_state: "started"
nginx_container_volumes: []
nginx_container_log_options: {
  labels: "{{ nginx_container_name }}",
}
nginx_container_ports:
  - 443:443
  - 80:80

Add Role to Your Project:

Include the role in your requirements file (e.g., requirements.yml):

- src: https://github.com/lexa-uw/ansible-role-nginx-in-docker
  version: v2.0.0
  name: nginx

Install the Role: Run the command ansible-galaxy install -r ./requirements.yml --roles-path ./roles/

Playbook Example:

- hosts: all
  vars_files:
    - vars/main.yml
  roles:
    - { role: nginx }

Inside vars/main.yml

nginx_allow:
  - "127.0.0.1"  # Localhost
  - "1.1.1.1"    # Example allowed IP
nginx_dir: "{{ansible_env.PWD}}/docker/nginx"  # Set Nginx directory
nginx_htpasswd:
  - "admin:$apr1nuGQ0aW41nBe8nisbHRz4JZ9vq43u"  # User credentials
nginx_openssl_dhparam_numbits: 4096  # DH param bits

nginx_container_image: "nginx:1.15.9-alpine"  # Specify Nginx image
nginx_container_name: "nginx"  # Name of the container
nginx_container_network_mode: "host"  # Network mode
nginx_container_ports: []  # No specific ports
Informazioni sul progetto

Install Nginx in Docker container.

Installa
ansible-galaxy install lexa-uw.nginx-in-docker
Licenza
Unknown
Download
137
Proprietario