gortc.nginx

Ansible Role: Nginx

Build Status

This role installs Nginx on various servers like RedHat/CentOS, Debian/Ubuntu, Archlinux, FreeBSD, or OpenBSD.

It installs and sets up the latest version of Nginx using the appropriate package manager for the system (yum for RedHat-based systems, apt for Debian-based systems, etc.). After installation, you may need to create your own virtual host configuration file in /etc/nginx/conf.d/ to set options for your website.

Requirements

No special requirements.

Role Variables

Here are the available variables and their default values (see defaults/main.yml):

  • nginx_vhosts: []
    • A list of virtual host definitions for Nginx. Each entry creates a separate config file based on server_name. If you don't add any, you must provide your own configuration.
nginx_vhosts:
  - listen: "443 ssl http2"
    server_name: "example.com"
    # More settings...
  • nginx_remove_default_vhost: false

    • Removes the default virtual host provided by Nginx.
  • nginx_upstreams: []

    • Use this to define upstream servers if you set Nginx as a load balancer.
  • nginx_user: "nginx"

    • The user that Nginx will run as.
  • nginx_worker_processes: computed automatically

    • Set to the number of cores on your server.
  • nginx_worker_connections: "1024"

    • The number of simultaneous connections Nginx can handle.
  • nginx_error_log: "/var/log/nginx/error.log warn"

    • Where Nginx will log errors.
  • nginx_sendfile: "on"

    • Use sendfile for faster file transfers.
  • nginx_keepalive_timeout: "65"

    • Timeout settings for keepalive connections.
  • nginx_client_max_body_size: "64m"

    • Maximum file upload size.
  • nginx_proxy_cache_path: ""

    • Path for caching if you set Nginx as a reverse proxy.

You can also add extra settings in the http section of nginx.conf or modify the provided templates for more customization.

Overriding Templates

If you want to customize settings not exposed as variables, you can override the template used for the virtual host or the main nginx.conf file:

nginx_conf_template: "nginx.conf.j2"
nginx_vhost_template: "vhost.j2"

You can create child templates to extend these templates as needed.

Example Playbook

Here is a simple example of how to use this role in a playbook:

- hosts: server
  roles:
    - { role: geerlingguy.nginx }

License

MIT / BSD

Author Information

This role was created in 2014 by Jeff Geerling, author of Ansible for DevOps.

Informazioni sul progetto

Nginx installation for Linux, FreeBSD and OpenBSD.

Installa
ansible-galaxy install gortc.nginx
Licenza
mit
Download
101
Proprietario
Archived, please use @pion (was WebRTC stack in go)