viasite-ansible.nginx-vhosts
Ansible 角色: Nginx 虚拟主机
目的
我使用这个角色作为 viasite-ansible.site 的一部分,来加快网站的配置速度。
这是一个精简版的 jdauphant.nginx。 在使用这个角色之前,必须先配置 jdauphant.nginx。
在我的机器上,配置一个站点所需的时间从 48 秒(使用 --skip-tags package
)减少到 7 秒。
功能
- 添加站点
- 删除站点
其他功能在完整的 jdauphant.nginx 角色中实现。
使用方法
请参见 jdauphant 的文档。
示例剧本
- hosts: all
roles:
- viasite-ansible.nginx-vhosts
vars:
nginx_sites:
foo:
template: "site.conf.j2"
bar:
- listen 8080
- server_name localhost
- root "/tmp/site1"
- location / { try_files $uri $uri/ /index.html; }
- location /images/ { try_files $uri $uri/ /index.html; }
nginx_remove_sites:
- baz