Giter Site home page Giter Site logo

nginx's Introduction

nginx

This role installs and configures the nginx web server. The user can specify any http configuration parameters they wish to apply their site. Any number of sites can be added with configurations of your choice.

Requirements

This role requires Ansible 1.4 or higher and platform requirements are listed in the metadata file.

Role Variables

The variables that can be passed to this role and a brief description about them are as follows.

# The max clients allowed
nginx_max_clients: 512                                

# A hash of the http paramters. Note that any
# valid nginx http paramters can be added here.
# (see the nginx documentation for details.)
nginx_http_params:                                    
  sendfile: "on"                                      
  tcp_nopush: "on"
  tcp_nodelay: "on"
  keepalive_timeout: "65"
  access_log: "/var/log/nginx/access.log"
  error_log: "/var/log/nginx/error.log"

# A list of hashs that define the servers for nginx,
# as with http parameters. Any valid server parameters
# can be defined here.
nginx_sites:                                         
 - server:                                           
    file_name: foo
    listen: 8080
    server_name: localhost
    root: "/tmp/site1"
    location1: {name: /, try_files: "$uri $uri/ /index.html"}
    location2: {name: /images/, try_files: "$uri $uri/ /index.html"}
 - server:
    file_name: bar
    listen: 9090
    server_name: ansible
    root: "/tmp/site2"
    location1: {name: /, try_files: "$uri $uri/ /index.html"}
    location2: {name: /images/, try_files: "$uri $uri/ /index.html"}

Examples

  1. Install nginx with HTTP directives of choices, but with no sites configured:

    • hosts: all roles:
      • {role: nginx, nginx_http_params: { sendfile: "on", access_log: "/var/log/nginx/access.log"}, nginx_sites: none }
  2. Install nginx with different HTTP directives than previous example, but no sites configured.

    • hosts: all roles:
      • {role: nginx, nginx_http_params: { tcp_nodelay: "on", error_log: "/var/log/nginx/error.log"}, nginx_sites: none }

Note: Please make sure the HTTP directives passed are valid, as this role won't check for the validity of the directives. See the nginx documentation for details.

  1. Install nginx and add a site to the configuration.

    • hosts: all

      roles:

      • role: nginx, nginx_http_params: sendfile: "on" access_log: "/var/log/nginx/access.log" nginx_sites:
        • server: file_name: bar listen: 8080 location1: {name: "/", try_files: "$uri $uri/ /index.html"} location2: {name: /images/, try_files: "$uri $uri/ /index.html"}

Note: Each site added is represented by list of hashes, and the configurations generated are populated in /etc/nginx/sites-available/ and have corresponding symlinks from /etc/nginx/sites-enabled/

The file name for the specific site configurtaion is specified in the hash with the key "file_name", any valid server directives can be added to hash. For location directive add the key "location" suffixed by a unique number, the value for the location is hash, please make sure they are valid location directives.

  1. Install Nginx and add 2 sites (different method)


    • hosts: all roles:
      • role: nginx nginx_http_params: sendfile: "on" access_log: "/var/log/nginx/access.log" nginx_sites:
        • server: file_name: foo listen: 8080 server_name: localhost root: "/tmp/site1" location1: {name: /, try_files: "$uri $uri/ /index.html"} location2: {name: /images/, try_files: "$uri $uri/ /index.html"}
        • server: file_name: bar listen: 9090 server_name: ansible root: "/tmp/site2" location1: {name: /, try_files: "$uri $uri/ /index.html"} location2: {name: /images/, try_files: "$uri $uri/ /index.html"}

Dependencies

None

License

BSD

Author Information

Benno Joy

nginx's People

Contributors

bennojoy avatar srgvg avatar tgerla avatar ycombinator avatar

Watchers

 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.