Coder Social home page Coder Social logo

ansible-role-nginx's Introduction

ansible-role-nginx

A versatile role to setup nginx, created using this philosophy: https://github.com/jriguera/ansible-role-pattern/blob/master/README.md

Ansible 2.0, works with Ubuntu Trusty, Xenial and Centos 7

This role supports the definition of different vhosts and parameters, for example, it is capable of copying ssl certificates to the server if they are defined.

Configuration

Have a look at the default configuration parameters defined in default/main.yml

You can see some examples there. For instance, to define a virtual host with all available options (name is the only required parameter):

nginx_server_list:
  - name: "example.com"
    root: "/var/www/example.com"
    delete: False
    listen: 
      - ["80", "default_server"]
      - ["443", "ssl"]
    alias: ["www.example.com"]
    charset: "utf-8"
    disable_symlinks: "off"
    limit_rate: 0
    limit_rate_after: 0
    error_page: ["404", "/404.html"]
    access_log: "/var/log/nginx/name_access.log"
    index: ["index.html", "index.htm"]
    rewrite: 
      - "^/users/(.*)$ /show?user=$1? last"
    return: "403"
    location_list:
      - name: "^~ /images/"
        confiration: "parameters"
        try_files: "$uri $uri/ 404"

Example with a proxy backend

nginx_server_list:
  - name: "proxybackend"
    delete: False
    listen: 
      - ["80", "default_server"]
    access_log: "/var/log/nginx/name_access.log"
    upstream:
      strategy: "ip_hash"
      server_list:
        - "srv1.example.com"
        - "srv2.example.com weight=3"
        - "srv3.example.com"
    location_list:
      - name: "/"
        proxy_pass: "http://proxybackend"

You can overwrite these default parameters as role variables. Have a look at the example in site.yml with vagrant and test it by using vagrant up.

Author

José Riguera López [email protected]

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.