skies-io / puppet-openresty

A puppet module to handle openresty configuration and installation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

puppet-openresty

A puppet module to handle openresty configuration and installation

Usage

Basic

include openresty

Upstream

  openresty::upstream {"phpfastcgi":
    ensure  => present,
    members => [
                '127.0.0.1:9000',
                ],
    notify => Service['openresty'],
  }

Advanced Site

  openresty::site {"mywebsite.io":
    ensure => enable,
    listen_port => '80',
    gzip => 'yes',
    server_name => ["mywebsite.io"],
    ssl => 'no',
    log_access => "/space/log/access.log",
    log_error => "/space/log/error.log",
    root => "/space/mywebsite/public/",
    locations => {
      '~ \.php$' => {
        'root' => "/space/mywebsite/public/",
        "include" => "/usr/local/openresty/nginx/conf/fastcgi.conf",
        'custom_params' => {
          "access_log" => "/space/log/upstream.log  upstream",
          "fastcgi_pass" => "phpfastcgi",
        }
      },
      '/' => {
        'root' => "/space/mywebsite/public/",
        "need_auth" => "true",
        "auth_basic" => "authentication",
        "auth_basic_user_file" => "/space/auth.conf",
        'index' => "index.php",
        'custom_params' => {
          "try_files" => '$uri $uri/ /index.php$is_args$args',
          "satisfy" => "any",
          "access_by_lua" => "'
                          local uri = ngx.var.request_uri
                          local redis = require \"resty.redis\"
                          local red = redis:new()

                          red:set_timeout(1000)

                          local ok, err = red:connect(\"127.0.0.1\", 6379)
                          if not ok then
                              ngx.log(ngx.ERR, \"Failed to connect to Redis: \", err)
                              return ngx.exit(500)
                          end
                      '",
        }
      },
    },
    require => [File["/space/mywebsite"]],
  }

About

A puppet module to handle openresty configuration and installation

License:MIT License


Languages

Language:Puppet 50.6%Language:HTML 46.2%Language:Ruby 3.2%