lunik.nginx
Ansible 角色:Nginx
在 Linux 上安装 Nginx 并配置服务和网站模板。
需求
无。
角色变量
变量 | 类型 | 描述 |
---|---|---|
nginx_ssl_source_cert_path |
字符串 | Ansible 主控上 SSL 证书的路径 |
nginx_ssl_source_key_path |
字符串 | Ansible 主控上 SSL 密钥的路径 |
nginx_ssl_source_passphrase_path |
字符串 | Ansible 主控上 SSL 密钥口令的路径 |
nginx_ssl_protocols |
列表(字符串) | 用于 SSL/TLS 的协议列表 |
nginx_ssl_ciphers |
字符串 | 用于 SSL/TLS 的密码套件列表 |
nginx_config_site_only |
布尔值 | 仅运行网站配置,跳过 Nginx 服务安装 |
nginx_sites |
列表(对象) | 网站对象列表 |
nginx_sites
这一部分说明如何配置 Nginx 网站。
每个 site
定义如下属性:
变量 | 类型 | 描述 |
---|---|---|
enabled |
布尔值 | 是否启用该网站在 Nginx 服务器上的使用 |
params |
映射(任意) | Nginx 服务器接受的所有参数的映射 |
依赖
无。
示例剧本
- hosts: localhost
vars:
nginx_ssl_source_cert_path: "/path/to/ssl/cert.crt"
nginx_ssl_source_key_path: "/path/to/ssl/cert.key"
nginx_ssl_source_passphrase_path: "/path/to/ssl/cert.passphrase"
nginx_sites:
- name: my-app
enabled: yes
params:
server_name: "my-app.local"
location:
path: /
params:
proxy_pass: "http://127.0.0.1:5000"
- name: my-app
enabled: yes
params:
server_name: "my-app.local"
root: /var/www/html
index: index.html
location:
path: /
params:
try_files: "$uri $uri/ =404"
roles:
- lunik.nginx
许可
作者信息
该角色由 Lunik (Guillaume MARTINEZ) 于 2019 年创建。