artem_shestakov.nginx
Ansible Nginx 角色
=========
Ansible 角色用于在 Debian/Red Hat 操作系统上安装 Nginx。
需求
无
变量
此角色使用三种类型的变量。第一和第二种取决于安装类型。第三种是与安装类型无关的一般变量。
一般变量
- install_from - Nginx 安装类型。[source | repo]。默认值:
repo
- nginx_http_add - 将添加到 Nginx 配置文件 http 部分的附加参数列表。默认值:[]
- nginx_stream_add - 将添加到 Nginx 配置文件 stream 部分的附加参数列表。默认值:[]
- ssl_cert_path - Nginx 使用的 SSL 证书的目录。默认值:
\etc\nginx\ssl
Web 服务器
- nginx_virtual_servers - 虚拟服务器列表。默认值:[]
- listen - 指定服务器监听请求的 IP 地址和端口(或 Unix 域套接字和路径)
- server_name - 虚拟服务器的名称列表
- locations - 位置 列表
- location - 根据请求 URI 的配置。
- params - 为位置设置参数。例如
proxy_pass
、return
、rewrite
等等。
TCP 和 UDP 负载均衡
- tcp_udp_nlb - TCP 和 UDP 负载均衡的后端服务器字典列表,包括字段
- name - upstream 的名称
- listen - Nginx 代理监听传入流量的端口
- servers - 后端服务器列表
- stub_status - 如果为真,则角色将通过 ngx_http_stub_status_module 设置 Nginx 监控工具。默认值:
false
- stub_status_settings - stub_status 设置的字典,包含字段
- listen - 设置服务器接受请求的 IP 地址和端口或 UNIX 域套接字的路径。默认值:
127.0.0.1:80
- server_name - 设置虚拟服务器的名称。默认值:
127.0.0.1
- location - 根据请求 URI 设置配置。默认值:
/nginx_status
- listen - 设置服务器接受请求的 IP 地址和端口或 UNIX 域套接字的路径。默认值:
SSL
- proxy_ssl - 为连接到代理服务器启用 SSL/TLS 协议。
- proxy_ssl_certificate - 指定用于身份验证的使用 PEM 格式的证书文件,用于代理 HTTPS 服务器
- proxy_ssl_certificate_key - 指定用于身份验证的 PEM 格式的私钥文件。
- proxy_ssl_ciphers - 指定连接到代理服务器所启用的密码。密码以 OpenSSL 库理解的格式指定。
- ssl_certificate - 指定给定虚拟服务器的 PEM 格式的私钥文件。
- ssl_certificate_key - 指定用于身份验证的 PEM 格式的私钥文件,用于代理服务器。
从仓库安装变量
从源代码安装变量
- nginx_with_modules - 非默认 Nginx 模块的列表。模块列表见 此处。默认值:[]
示例 Playbook
---
- name: 安装 Nginx 应用
hosts: all
remote_user: vagrant
become: true
roles:
- artem_shestakov.nginx
vars:
- install_from: source
- nginx_with_modules:
- --with-file-aio
- --with-ipv6
- --with-http_ssl_module
- --with-http_v2_module
- --with-http_realip_module
- --with-http_addition_module
- --with-http_xslt_module=dynamic
- --with-http_image_filter_module=dynamic
- --with-http_sub_module
- --with-http_dav_module
- --with-http_flv_module
- --with-http_mp4_module
- --with-http_gunzip_module
- --with-http_gzip_static_module
- --with-http_random_index_module
- --with-http_secure_link_module
- --with-http_degradation_module
- --with-http_slice_module
- --with-http_stub_status_module
- --with-http_perl_module=dynamic
- --with-http_auth_request_module
- --with-mail=dynamic
- --with-mail_ssl_module
- --with-stream=dynamic
- --with-stream_ssl_module
- --with-debug
- tcp_udp_nlb:
- name: example
listen:
- 192.168.1.1:443
- 192.168.1.2:443
servers:
- 10.79.1.196:443
- name: example2
listen:
- 10002
servers:
- 10.79.1.203:5601
将证书复制到 Nginx 服务器
- 将您的证书放入目录中
- 设置变量
- copy_ssl_certs - 如果需要从本地机器复制您的证书到远程 Nginx 服务器,则为 true
- user_certs_path - 需要复制到 Nginx 的 SSL 证书目录列表。默认值:[
./files/ssl/*
]
许可证
BSD, MIT
作者信息
Artem Shestakov (artem.s.shestakov@gmail.com)