nycrecords.nginx

Ansible Role: Nginx

License
Build Status
Galaxy
Ansible
Ansible

Note: Please think about using the official NGINX Ansible role from NGINX, Inc.

This role helps you install Nginx on different types of servers like RedHat/CentOS, Debian/Ubuntu, Archlinux, FreeBSD, or OpenBSD. It fetches the latest version of Nginx from the Nginx repositories specific to your server type. You may need to do some additional steps after installation, like creating your own virtualhost.conf file in /etc/nginx/conf.d/ to define your website's settings.

Requirements

  • Ansible version 2.4 or higher.
  • For RedHat-based systems, you need the EPEL repository or a valid RedHat Subscription (you can ensure EPEL is available by adding the role geerlingguy.repo-epel).

Role Variables

Here are some variables you can configure (the default values can be found in defaults/main.yml):

  • nginx_vhosts: This is where you define virtual hosts for Nginx. Each entry creates a config file. If you don’t add any entries, you must provide your own configuration later.

Example of a virtual host:

nginx_vhosts:
  - listen: "443 ssl http2"
    server_name: "example.com"
    root: "/var/www/example.com"
    index: "index.php index.html"
    filename: "example.com.conf"
  • nginx_remove_default_vhost: Set this to true to remove the default Nginx virtual host. This is helpful if you want a custom URL to point to your own virtual host.

  • nginx_upstreams: If you are using Nginx as a load balancer, define upstream servers here.

  • nginx_user: The user under which Nginx runs, defaulting to nginx or www-data based on the OS.

  • nginx_error_log and nginx_access_log: Set the paths for the error and access logs.

  • nginx_keepalive_timeout: This is the duration for keeping connections alive, adjust based on your site's traffic.

  • nginx_client_max_body_size: This controls the maximum file size allowed for uploads through Nginx.

Customizing Configuration

If you need more control over the Nginx configuration templates, you can override the default ones:

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

You can create your own templates and specify them for specific virtual hosts.

Example Playbook

Here’s 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 by Jeff Geerling in 2014 and later modified by Joel Castillo for the NYC Department of Records and Information Services.

Informazioni sul progetto

Nginx installation for Linux, FreeBSD and OpenBSD.

Installa
ansible-galaxy install nycrecords.nginx
Licenza
mit
Download
115
Proprietario