147 Commits
1.0.7 ... 1.3.5

Author SHA1 Message Date
Emilien Mantel
ae167d3317 Disabling htpasswd by setting false 2017-03-08 11:10:14 +01:00
Emilien Mantel
d8f241f79c Fix headers quotes on nagios 2017-02-09 12:30:13 +01:00
Emilien Mantel
0e33d1b372 Auto quote headers values 2017-02-09 12:03:14 +01:00
Emilien Mantel
2cd559b87a Fix X-XSS-Protection with quotes 2017-02-09 11:59:33 +01:00
Emilien Mantel
d550f1bab1 Read-only var: nginx_servers_default_headers 2017-02-08 16:16:19 +01:00
Emilien Mantel
021ca4e173 Auto add "X-XSS-Protection" header to servers 2017-02-08 15:59:02 +01:00
Emilien Mantel
38a8354754 Bind proxy_protocol on port 2017-01-03 12:07:31 +01:00
Emilien Mantel
1b06fe273f Add html file to test-ssl-proxy-protocol.local 2017-01-03 11:32:45 +01:00
Emilien Mantel
684c794566 Manage proxy protocol 2017-01-03 11:16:28 +01:00
Emilien Mantel
f2cfae31b1 Update APT cache should not "change" 2016-12-08 17:34:59 +01:00
Emilien Mantel
481bcd34b1 no_log while creating SSL directories 2016-12-08 09:19:12 +01:00
Emilien Mantel
875c7cfb2e Async task: generate dh 2016-12-07 07:48:32 +01:00
Emilien Mantel
8caddedc68 Deploy custom facts with nginx_vhosts 2016-11-29 14:32:27 +01:00
Emilien Mantel
4a3aed6974 no_log on task : Deploy SSL certs 2016-11-29 09:35:53 +01:00
Emilien Mantel
8ccc9f521f Secure files permission 2016-11-25 11:33:20 +01:00
Emilien Mantel
5b0977567c New feature: provide location order (#24 related) 2016-11-23 11:44:04 +01:00
E Mantel
de71e1bdcc Better display for server_name 2016-11-16 20:51:03 +01:00
Emilien Mantel
19cdab5ba4 default vhost on HTTPS redirect 2016-11-15 17:15:39 +01:00
Emilien Mantel
999f226838 Delete useless test 2016-11-07 17:40:00 +01:00
Emilien Mantel
40f67fc103 Vhost ssl_name name is now optionnal 2016-11-07 17:22:14 +01:00
Emilien Mantel
6b1366298f no_log on sensitive data 2016-11-02 14:48:49 +01:00
Emilien Mantel
817d56fb81 Fix redirect https on non standard port 2016-11-02 14:25:27 +01:00
Emilien Mantel
e08401acf8 vhost redirect_from accepts string 2016-11-02 14:23:55 +01:00
Emilien Mantel
0bda544a2f Revert "nginx -t has no side effect"
This reverts commit 2641777abe.
2016-11-02 14:21:32 +01:00
Emilien Mantel
2641777abe nginx -t has no side effect 2016-10-27 17:48:57 +02:00
Emilien Mantel
60a368f3e1 Manage many configurations 2016-10-13 11:11:07 +02:00
Emilien Mantel
41a5575627 Dynamic modules starts at version 1.9.11 2016-10-12 18:16:53 +02:00
Emilien Mantel
42bb4a3e2b Dynamic module management (closes #23) 2016-10-12 18:13:59 +02:00
Emilien Mantel
ef3440a015 Bug fix: vhost with absent state is not deleted in sites-enabled 2016-10-10 14:35:46 +02:00
Emilien Mantel
eb704da8d8 README improvement pour vhost.filename 2016-10-07 11:01:00 +02:00
Emilien Mantel
64a9ab7c68 Better display in _base.j2 with many server_name 2016-10-07 10:57:26 +02:00
Emilien Mantel
c4ee6eb1a2 vhost.filename used by log and directories creation 2016-10-07 10:50:05 +02:00
Emilien Mantel
8789bd2c9c Add some security rules for wordpress 2016-09-03 12:43:28 +02:00
Emilien Mantel
a2e6e98436 Add new feature: nginx_fastcgi_fix_realpath 2016-08-30 17:14:34 +02:00
E Mantel
fc44b704cf Merge pull request #22 from HanXHX/vhost_state
Vhost state
2016-08-30 12:28:44 +02:00
Emilien Mantel
cf662acdd7 Fix condition when creating vhosts 2016-08-30 11:18:14 +02:00
Emilien Mantel
34c8d1926f Vhost state (closes #19) 2016-08-30 11:06:38 +02:00
Emilien Mantel
634d88874f Backward compatibility with nginx_php variable 2016-08-30 10:52:28 +02:00
Emilien Mantel
5e254331c4 manage php upstream version (styles) on vhost 2016-08-26 12:14:54 +02:00
Emilien Mantel
3ab8e0391c Disable tests for owncloud (fix later) 2016-08-25 18:19:07 +02:00
Emilien Mantel
aac33b7376 better vhost for owncloud 2016-08-11 13:03:56 +02:00
Emilien Mantel
88c6c5a043 Manages PHP minor versions 2016-08-11 11:30:26 +02:00
Emilien Mantel
a9ad41b40f Fix more block for owncloud 2016-08-11 11:09:43 +02:00
Emilien Mantel
d26b2b9a49 Fix owncloud root 2016-08-11 10:59:44 +02:00
Emilien Mantel
b17acac4c4 Tests packages on Debian 2016-08-11 10:48:12 +02:00
Emilien Mantel
c160640c7f Force latest version of openssl when uses nginx from backports 2016-08-11 10:36:50 +02:00
Emilien Mantel
887219f86c Force install OpenSSL from backports when nginx uses backports 2016-08-11 10:25:45 +02:00
Emilien Mantel
76c02abf47 Fix owncloud js (from php) and add tests 2016-08-11 09:38:09 +02:00
Emilien Mantel
26c93c9315 Add owncloud and prevent nginx from dotdeb 2016-08-10 21:29:03 +02:00
Emilien Mantel
8fb3829860 Drop Wheezy support in IC 2016-08-09 16:12:54 +02:00
Emilien Mantel
e4b5bb2a32 Support many php versions (php7) + drop wheezy support 2016-08-09 16:02:09 +02:00
Emilien Mantel
af3930a58a New feature: upstream state (remove upstream if needed) 2016-05-11 17:21:52 +02:00
Emilien Mantel
4dcb5f44c6 Don't need any inventory file for tests 2016-03-23 17:27:59 +01:00
Emilien Mantel
1204dbacd1 [FreeBSD] Enable nginx service 2016-03-15 23:12:17 +01:00
Emilien Mantel
3087154335 [FreeBSD] restart nginx on vhost config changed 2016-03-15 23:00:55 +01:00
Emilien Mantel
72edbe8656 [FreeBSD] Force create log dir 2016-03-15 22:49:19 +01:00
E Mantel
66b2ac238c README: Change URL in galaxy 2016-03-15 19:48:00 +01:00
Emilien Mantel
d49e41652c Update cipher list (from https://cipherli.st/) 2016-03-15 17:59:48 +01:00
Emilien Mantel
9b19231d8b use headers instead of more 2016-03-15 17:15:46 +01:00
Emilien Mantel
80d1d82acc Fix handler (didn't reload service after nginx -t) 2016-03-15 17:15:11 +01:00
Emilien Mantel
5445d66172 Add a wrapper: test configuration before reloading (better debugging) 2016-03-15 15:57:46 +01:00
Emilien Mantel
9a5afd09fa Force X-Frame-Options SAMEORIGIN for Nagios (closes #17) 2016-03-15 15:46:49 +01:00
Emilien Mantel
96e406c791 always directive managed for add_header option 2016-03-15 15:30:22 +01:00
Emilien Mantel
02994af5ee Default headers with always directive 2016-03-15 15:01:58 +01:00
Emilien Mantel
ee79ec9845 SSL helper can be disabled 2016-03-15 12:16:57 +01:00
Emilien Mantel
2ba906be2e Add custom headers in vhost (moved from ssl helpers) 2016-03-15 10:51:14 +01:00
Emilien Mantel
d223f8b144 Add a check for HTTPS redirect 2016-03-15 09:22:01 +01:00
Emilien Mantel
8f837de390 Avoid double / in redirect_https 2016-03-15 09:08:52 +01:00
Emilien Mantel
aa4bc8d6a7 Move to new galaxy version 2016-03-14 19:39:11 +01:00
Emilien Mantel
2fcf7fa701 Delete useless files 2016-03-14 19:37:25 +01:00
Emilien Mantel
91686fc266 doc minor fix 2016-03-14 19:27:51 +01:00
Emilien Mantel
5e493c15ac Fix deprecation warning 2016-03-14 19:21:47 +01:00
Emilien Mantel
97aeda5678 New feature: redirect_https (HTTP -> HTTPS) 2016-03-14 19:20:08 +01:00
Emilien Mantel
3666b29184 nghttp2 only on Debian Jessie+ 2016-03-09 15:03:41 +01:00
Emilien Mantel
9b5f136510 Fix trailing whitespaces 2016-03-09 11:20:19 +01:00
Emilien Mantel
7cc44bc009 Fix regression (merge?): filename for vhosts 2016-03-09 11:15:37 +01:00
Emilien Mantel
078c3420e1 Fix Vagrantfile (debian is not freebsd)... uh? :) 2016-03-09 10:28:06 +01:00
Emilien Mantel
2cfda9a930 Fix check HTTP2 on FreeBSD (multi-OS code) 2016-03-08 19:37:39 +01:00
E Mantel
29a40fc0a8 Merge pull request #14 from HanXHX/freebsd
Freebsd support
2016-03-08 18:59:38 +01:00
Emilien Mantel
33f34a0550 Manage FreeBSD nginx package name 2016-03-07 12:08:34 +01:00
Emilien Mantel
8fc6f7117e Doc fixes 2016-03-07 12:05:58 +01:00
Emilien Mantel
972555ce22 Minor fixes 2016-03-07 11:59:26 +01:00
Emilien Mantel
2f0672359d I support now FreeBSD! 2016-03-05 18:43:49 +01:00
Emilien Mantel
cdc152afbe Nagios OK on FreeBSD 2016-03-05 18:34:04 +01:00
Emilien Mantel
729b621ccb Fix check htpasswd in location (replace echo test) 2016-03-05 17:31:21 +01:00
Emilien Mantel
c13cb0d770 PHP works on FreeBSD 2016-03-05 17:26:05 +01:00
Emilien Mantel
8edd69547d [WIP] split pre/post tasks related to OS version 2016-03-05 15:46:54 +01:00
Emilien Mantel
791832f6d1 Config seems ok 2016-03-05 15:36:25 +01:00
Emilien Mantel
e00313bb36 [WIP] FreeBSD install ok 2016-03-05 15:07:39 +01:00
Emilien Mantel
44a5c31b12 Typofix 2016-03-05 12:12:09 +01:00
Emilien Mantel
232e63dffe Add travis webhook to galaxy 2016-03-05 12:06:08 +01:00
Emilien Mantel
fe68e17663 Logging must be set to false to be disabled 2016-03-05 12:00:07 +01:00
Emilien Mantel
ac61b3df0a Add new galaxy tags 2016-03-05 11:40:43 +01:00
Emilien Mantel
1071881ac2 Merge branch 'master' of https://github.com/HanXHX/ansible-nginx
Conflicts:
	tasks/vhost.yml
2016-03-05 11:39:29 +01:00
Emilien Mantel
e139ab3e35 Fix deprecation warnings 2016-03-05 11:37:37 +01:00
Emilien Mantel
1f82e7adfe Add HTTP2 check 2016-03-05 11:30:48 +01:00
Emilien Mantel
e43a958b03 Gitignore *.retry 2016-03-05 11:06:34 +01:00
Emilien Mantel
47c24a2eb3 Fix HTTP2 syntax error 2016-03-05 10:59:20 +01:00
Emilien Mantel
82c44be932 Use official debian box and DHCP 2016-03-05 10:46:46 +01:00
Emilien Mantel
781008dfff Each vhost can have his own filename 2016-03-04 16:38:40 +01:00
Emilien Mantel
26a50945c5 Split apt update cache (fix install when cache is outdated) 2016-02-09 18:36:48 +01:00
Emilien Mantel
4dc28d9471 Delete useless tasks 2016-02-09 17:17:44 +01:00
Emilien Mantel
3231e58bc0 Test stub status on default http vhost 2016-02-09 16:57:13 +01:00
Emilien Mantel
d4f9b6f710 Fix default var nginx_custom_http 2016-01-26 11:19:51 +01:00
Emilien Mantel
d049be0d81 Remove duplicate link 2016-01-25 17:02:17 +01:00
Emilien Mantel
863dc6ca76 In tests, dh = 1024bits (speedup tests) 2016-01-22 10:06:35 +01:00
Emilien Mantel
1338e4dee6 Fix indent 2016-01-22 09:52:15 +01:00
Emilien Mantel
dd97e5ec79 Apps vhosts should without root and created dirs 2016-01-22 09:46:43 +01:00
Emilien Mantel
7f56db76e0 Simplify proxy template 2016-01-22 09:36:52 +01:00
Emilien Mantel
51a1105dff Check PHP (should fix travis) 2016-01-21 17:54:24 +01:00
Emilien Mantel
0a8f21b0b7 Min ansible version is now 2.0 (closes #10) 2016-01-21 17:10:36 +01:00
Emilien Mantel
75d815b4a4 Revert "Bypass htpasswd module bug (state=absent on missing file)"
This reverts commit f8d138828b.
2016-01-21 17:09:54 +01:00
Emilien Mantel
520eed50c3 Manage default vhost. Closes #11 2016-01-21 17:08:01 +01:00
Emilien Mantel
c36c4824b7 Cleanup tests 2016-01-21 15:34:18 +01:00
Emilien Mantel
c357658c25 Fix Nagios vhost and better tests 2016-01-21 15:16:21 +01:00
Emilien Mantel
be349ec686 new vhost: nagios3 (without css) 2016-01-15 15:48:18 +01:00
Emilien Mantel
287d154532 SSL strapling on Nginx >= 1.3.7 2016-01-15 12:13:15 +01:00
Emilien Mantel
11c98ab145 SSL with existing keys 2016-01-12 17:26:30 +01:00
Emilien Mantel
ef5a7bf756 Closes #9 2016-01-12 15:10:43 +01:00
Emilien Mantel
2f6f2d4362 Fix variable check 2016-01-12 15:01:01 +01:00
Emilien Mantel
53b9dc078e Minor changes on doc 2016-01-12 14:48:53 +01:00
Emilien Mantel
ccba868390 Improve checks SSL/TLS + vhost 2016-01-12 14:40:09 +01:00
Emilien Mantel
9b6523a0b1 Doc split + SSL + minor changes 2016-01-12 12:14:36 +01:00
Emilien Mantel
883948f081 Better dh management 2016-01-12 11:16:41 +01:00
Emilien Mantel
ad9c0fa979 Fix main name in vhosts 2016-01-12 09:27:53 +01:00
Emilien Mantel
8a30223bb9 Fix upstream (php is optional) 2016-01-11 23:55:33 +01:00
Emilien Mantel
49f11751e6 Refactoring + SSL support 2016-01-11 18:20:42 +01:00
Emilien Mantel
f64e1f1106 New feature: install nginx from backports 2016-01-11 15:18:21 +01:00
Emilien Mantel
d463b690ec Force start backuppc 2015-12-23 22:37:37 +01:00
Emilien Mantel
7c9c7ab474 Try fix travis with fcgiwrap (down?) 2015-12-23 18:03:17 +01:00
Emilien Mantel
c703a4fba8 Support BackupPC 2015-12-23 17:39:06 +01:00
Emilien Mantel
e0bb5e2752 Add feature: new custom instructions 2015-12-09 17:06:59 +01:00
Emilien Mantel
05cb864c7c Use more vars instead of a bug dirty dict 2015-12-09 16:46:50 +01:00
Emilien Mantel
f8d138828b Bypass htpasswd module bug (state=absent on missing file) 2015-12-04 08:54:59 +01:00
Emilien Mantel
1d86ed9a40 Add htpasswd doc 2015-12-03 17:24:58 +01:00
Emilien Mantel
f9127f9a40 Manage auth basic on all vhost 2015-12-03 17:09:29 +01:00
Emilien Mantel
88d1c7fdb7 Use macro for auth_basic 2015-12-03 16:59:37 +01:00
Emilien Mantel
c0f2d694e7 Meilleure gestion des dossiers et htpasswd par location 2015-12-03 16:32:08 +01:00
Emilien Mantel
0d65cd3c5c Add redirect_to_code in vhost 2015-12-01 16:40:34 +01:00
Emilien Mantel
9779555ac8 Few minor changes 2015-12-01 16:35:56 +01:00
Emilien Mantel
17905edf30 Begin Stretch support 2015-12-01 16:26:16 +01:00
Emilien Mantel
f2c6ec6c57 Travis badge on master branch 2015-12-01 15:52:10 +01:00
Emilien Mantel
80e3cae22e New feature on vhosts: "redirect_to" 2015-12-01 15:46:57 +01:00
Emilien Mantel
3fdc16578c Improve file deletions 2015-11-30 14:41:35 +01:00
Emilien Mantel
1d56fc249d Deleted vhost don't need a template 2015-11-30 12:16:17 +01:00
Emilien Mantel
bfe4a315f9 Vhost dir 2015-11-05 15:38:18 +01:00
Emilien Mantel
9fcba824f5 Create root directory 2015-11-04 09:16:59 +01:00
57 changed files with 1823 additions and 380 deletions

1
.gitignore vendored
View File

@@ -1,2 +1,3 @@
.vagrant* .vagrant*
*.swp *.swp
*.retry

View File

@@ -1,13 +1,20 @@
env: matrix:
- PLATFORM=debian-wheezy include:
- PLATFORM=debian-jessie - env: PLATFORM=debian-jessie ORIGIN=debian NGINX_PHP56=true NGINX_PHP70=false NGINX_BACKPORTS=false DOTDEB=false
- env: PLATFORM=debian-jessie ORIGIN=backports NGINX_PHP56=true NGINX_PHP70=false NGINX_BACKPORTS=true DOTDEB=false
- env: PLATFORM=debian-jessie ORIGIN=dotdeb NGINX_PHP56=true NGINX_PHP70=true NGINX_BACKPORTS=false DOTDEB=true
sudo: required sudo: required
dist: trusty
language: python language: python
services: services:
- docker - docker
script: script:
- docker build -f tests/$PLATFORM.Dockerfile -t test-$PLATFORM . && docker run --name $PLATFORM test-$PLATFORM - docker build -f tests/$PLATFORM.Dockerfile -t test-$PLATFORM . && docker run -e "DOTDEB=$DOTDEB" -e "NGINX_PHP56=$NGINX_PHP56" -e "NGINX_PHP70=$NGINX_PHP70" -e "NGINX_BACKPORTS=$NGINX_BACKPORTS" --name $PLATFORM test-$PLATFORM
notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/

150
README.md
View File

@@ -1,123 +1,82 @@
Nginx for Debian Ansible role Nginx for Debian/FreeBSD Ansible role
============================= =====================================
[![Ansible Galaxy](http://img.shields.io/badge/ansible--galaxy-HanXHX.nginx-blue.svg)](https://galaxy.ansible.com/list#/roles/4399) [![Build Status](https://travis-ci.org/HanXHX/ansible-nginx.svg)](https://travis-ci.org/HanXHX/ansible-nginx) [![Ansible Galaxy](http://img.shields.io/badge/ansible--galaxy-HanXHX.nginx-blue.svg)](https://galaxy.ansible.com/HanXHX/nginx/) [![Build Status](https://travis-ci.org/HanXHX/ansible-nginx.svg?branch=master)](https://travis-ci.org/HanXHX/ansible-nginx)
Install and configure Nginx on Debian. Install and configure Nginx on Debian/FreeBSD.
SSL management will come later. Features:
- SSL/TLS "hardened" support
- Manage basic auth on vhost / location
- Proxy + Upstream
- Fast PHP configuration
- Preconfigured vhost templates (should work on many app)
- Auto-configure HTTP2 on SSL/TLS vhosts
- Manage dynamic modules (install and loading)
- Deploy custom facts.d with sites config
- Can listen with proxy protocol
Requirements Requirements
------------ ------------
None. None. If you set true to `nginx_backports`, you must install backports repository before lauching this role.
Role Variables Role Variables
-------------- --------------
- `nginx_apt_package`: APT nginx package (try: apt-cache search ^nginx) ### Packaging
- `nginx_root`: root directory where you want to have your files
- `nginx_log_dir`: log directory (if you change it, don't forget to change logrotate config)
- `nginx_ssl_dir`: directory where you install your SSL/TLS keys
- `nginx_resolver`: list of DNS resolver (default: OpenDNS)
- `nginx_error_log_level`: default log level
- `nginx_dh_length`: DH key length (default is 2048)
### PHP Debian:
- `nginx_php`: boolean if you need to preconfigure PHP (default: false) - `nginx_apt_package`: APT nginx package (try: apt-cache search ^nginx)
- `nginx_php_sockets`: list of //sockets// - `nginx_backports`: Install nginx from backport repository (bool)
You should see [Nginx upstream module doc](http://nginx.org/en/docs/http/ngx_http_upstream_module.html). FreeBSD:
Socket: - `nginx_pkgng_package`: PKGNG nginx package (should be "nginx" or "nginx-devel")
- `unix_socket`
- `host` ### Shared
- `port`
- `weight` - `nginx_root`: root directory where you want to have your files
- `max_fails` - `nginx_log_dir`: log directory (if you change it, don't forget to change logrotate config)
- `fail_timeout` - `nginx_resolver`: list of DNS resolver (default: OpenDNS)
- `nginx_error_log_level`: default log level
- `nginx_auto_config_httpv2`: boolean, auto configure HTTP2 where possible
- `nginx_fastcgi_fix_realpath`: boolean, use realpath for fastcgi (fix problems with symlinks and PHP opcache)
### Nginx Configuration ### Nginx Configuration
- `nginx_user` - `nginx_user`
- `nginx_worker_processes` - `nginx_worker_processes`
- `nginx_events`: key/value in events block - `nginx_pid`: daemon pid file
- `nginx_http`: key/value in http block - `nginx_events_*`: all variables in events block
- `nginx_pid`: daemon pid file - `nginx_http_*`: all variables in http block
- `nginx_custom_http`: instructions list (will put data in `/etc/nginx/conf.d/custom.conf`)
- `nginx_dyn_modules`: dynamic module list to load
### Vhost management Fine configuration
------------------
You can see many examples in: [tests/test.yml](tests/test.yml). [Vhost configuration](doc/vhost.md)
- `nginx_vhosts`: List of dict. A vhost has few keys. See bellow. [PHP configuration](doc/php.md)
#### Common [Upstream Configuration](doc/upstream.md)
- `name`: (M) Domain or list of domain used. [SSL/TLS Configuration](doc/ssl.md)
- `template`: (M) template used to create vhost
- `enable`: (O) Enable the vhost (default is true)
- `delete`: (O) Delete the vhost (default is false)
- `redirect_from`: (O) Domain list to redirect to the first `name`. You can use this key to redirect non-www to www
- `location`: (O) Add new custom locations (it does not overwrite!)
- `more`: (O) Add more custom infos.
- `upstream_params`: (O) Add upstream params (useful when you want to pass variables to PHP)
- `override_try_files`: (O) overrides default try\_files defined in template
- `manage_local_content`: (O) Boolean. Set to false if you don't want to manage local content (images, css...). This option is useless if you use proxy `template`
(O) : Optional [Basic Auth](doc/auth.md)
(M) : Mandatory
#### Templates [FreeBSD](doc/freebsd.md)
- `base`: static template
- `dokuwiki`
- `phalcon`: Phalcon PHP Framework
- `php`: PHP base template. Can work with many frameworks/tools
- `php_index`: Same as above. But you can only run index.php
- `proxy`
- `wordpress`
Templates works as parent-child.
#### About proxy template
Proxy template allow you to use Nginx as reverse proxy. Usefull when you have application serveur such as Redmine, Jenkins...
You have many key added to vhost key:
- `upstream_name`: (O) upstream name used to pass proxy
- `proxy_params`: (M) list of raw params passed to the vhost
(O) : Optional
(M) : Mandatory
### Upstream management Note
----
- `nginx_upstreams`: List of dict. An upstream has few keys. See bellow. - Active support for Debian.
- FreeBSD support is experimental (no Travis). I only test (for the moment) 10.2 (but it can work on other versions).
Note: Few params are unavailable on old Nginx version. But this role don't put it if your version is too old! - I don't manage BackupPC for FreeBSD (PR welcome).
#### Upstream params
- `name`: upstream name. Can be use in vhost with *proxy_pass http://upstream_name*
- `params`: list of param (hash, zone...)
- `servers`: each upstream MUST have at least 1 server
#### Server params
You must set a `path`. For example: *192.168.0.50:8080* or *unix:/tmp/my.sock*.
All this params are optional. You should see [Nginx upstream doc](http://nginx.org/en/docs/http/ngx_http_upstream_module.html).
- `weight`
- `max`fails`
- `fail`timeout`
- `backup`
- `down`
- `route`
- `slow`start`
Dependencies Dependencies
------------ ------------
@@ -127,9 +86,7 @@ None
Example Playbook Example Playbook
---------------- ----------------
- hosts: servers See [tests/test.yml](tests/test.yml).
roles:
- { role: HanXHX.nginx }
License License
------- -------
@@ -139,4 +96,5 @@ GPLv2
Author Information Author Information
------------------ ------------------
- Twitter: https://twitter.com/hanxhx - Twitter: [@hanxhx_](https://twitter.com/hanxhx_)

43
Vagrantfile vendored
View File

@@ -5,9 +5,15 @@
Vagrant.configure("2") do |config| Vagrant.configure("2") do |config|
vms = [ vms_debian = [
[ "debian-wheezy", "deb/wheezy-amd64" , "192.168.33.27" ], { :name => "debian-jessie", :box => "debian/jessie64", :vars => { "nginx_php56": true, "nginx_php70": false, "dotdeb": false, "nginx_backports": false }},
[ "debian-jessie", "deb/jessie-amd64", "192.168.33.28" ] { :name => "debian-jessie-backports", :box => "debian/jessie64", :vars => { "nginx_php56": true, "nginx_php70": false, "dotdeb": false, "nginx_backports": true }},
{ :name => "debian-jessie-dotdeb", :box => "debian/jessie64", :vars => { "nginx_php56": true, "nginx_php70": true, "dotdeb": true, "nginx_backports": false }},
{ :name => "debian-stretch", :box => "sharlak/debian_stretch_64", :vars => { "nginx_php56": false, "nginx_php70": true, "dotdeb": false, "nginx_backports": false }}
]
vms_freebsd = [
{ :name => "freebsd-10.2", :box => "freebsd/FreeBSD-10.2-STABLE" }
] ]
config.vm.provider "virtualbox" do |v| config.vm.provider "virtualbox" do |v|
@@ -15,16 +21,35 @@ Vagrant.configure("2") do |config|
v.memory = 256 v.memory = 256
end end
vms.each do |vm| vms_debian.each do |opts|
config.vm.define vm[0] do |m| config.vm.define opts[:name] do |m|
m.vm.box = vm[1] m.vm.box = opts[:box]
m.vm.network "private_network", ip: vm[2] m.vm.network "private_network", type: "dhcp"
m.vm.provision "ansible" do |ansible| m.vm.provision "ansible" do |ansible|
ansible.playbook = "tests/test.yml" ansible.playbook = "tests/test.yml"
ansible.groups = { "test" => [ vm[0] ] }
ansible.verbose = 'vv' ansible.verbose = 'vv'
ansible.sudo = true ansible.sudo = true
ansible.extra_vars = opts[:vars]
end
end
end
# See: https://forums.freebsd.org/threads/52717/
vms_freebsd.each do |opts|
config.vm.define opts[:name] do |m|
m.vm.box = opts[:box]
m.vm.network "private_network", type: "dhcp"
m.vm.guest = :freebsd
m.vm.synced_folder ".", "/vagrant", id: "vagrant-root", disabled: true
m.ssh.shell = "sh"
m.vm.base_mac = "080027D14C66"
m.vm.provision "shell", inline: "pkg install -y python bash"
m.vm.provision "ansible" do |ansible|
ansible.playbook = "tests/test.yml"
ansible.verbose = 'vv'
ansible.sudo = true
ansible.extra_vars = {
ansible_python_interpreter: '/usr/local/bin/python'
}
end end
end end
end end

View File

@@ -1,30 +1,44 @@
--- ---
# Debian
nginx_apt_package: nginx-full nginx_apt_package: nginx-full
nginx_backports: false
# FreeBSD
nginx_pkgng_package: nginx
# #
# Nginx shared variables # Nginx shared variables
# #
nginx_root: "/srv/www" nginx_root: "/srv/www"
nginx_log_dir: '/var/log/nginx' nginx_log_dir: '/var/log/nginx'
nginx_ssl_dir: '/etc/nginx/ssl' nginx_resolver_hosts: ['8.8.8.8', '8.8.4.4']
nginx_pid: '/run/nginx.pid' nginx_resolver_valid: '300s'
nginx_resolver: nginx_resolver_timeout: '5s'
hosts: ['8.8.8.8', '8.8.4.4'] # OpenDNS
valid: '300'
timeout: '5'
nginx_error_log_level: 'warn' # http://nginx.org/en/docs/ngx_core_module.html#error_log nginx_error_log_level: 'warn' # http://nginx.org/en/docs/ngx_core_module.html#error_log
nginx_dh_length: 2048 nginx_auto_config_httpv2: true
nginx_default_vhost: null
nginx_default_vhost_ssl: null
nginx_fastcgi_fix_realpath: true
#
# Nginx directories
#
nginx_htpasswd_dir: '{{ nginx_etc_dir }}/htpasswd'
nginx_ssl_dir: '{{ nginx_etc_dir }}/ssl'
nginx_helper_dir: '{{ nginx_etc_dir}}/helper'
# #
# Load upstream # Load upstream
# #
# PHP # PHP
nginx_php: false nginx_php56: false
nginx_php_sockets: nginx_php70: false
- unix_socket: "/var/run/php5-fpm.sock" nginx_php56_sockets:
- unix_socket: "/run/php5-fpm.sock"
nginx_php70_sockets:
- unix_socket: "/run/php/php7.0-fpm.sock"
nginx_upstreams: []
# #
# Nginx configuration # Nginx configuration
@@ -32,43 +46,80 @@ nginx_php_sockets:
nginx_user: 'www-data' nginx_user: 'www-data'
nginx_worker_processes: '{{ ansible_processor_vcpus }}' nginx_worker_processes: '{{ ansible_processor_vcpus }}'
nginx_events: #
worker_connections: '512' # Nginx events
multi_accept: 'on' #
use: 'epoll' nginx_events_worker_connections: '512'
nginx_events_multi_accept: 'on'
# #
# Nginx HTTP # Nginx HTTP
# #
nginx_http: nginx_http_types_hash_max_size: 2048
access_log: 'off' nginx_http_default_type: 'application/octet-stream'
error_log: 'off' nginx_http_access_log: 'off'
client_body_buffer_size: '1M' nginx_http_error_log: 'off'
client_header_buffer_size: '1M' nginx_http_client_body_buffer_size: '1M'
client_max_body_size: '10M' nginx_http_client_header_buffer_size: '1M'
large_client_header_buffers: '8 8k' nginx_http_client_max_body_size: '10M'
client_body_timeout: '60' nginx_http_large_client_header_buffers: '8 8k'
client_header_timeout: '60' nginx_http_client_body_timeout: '60'
keepalive_timeout: '30 30' nginx_http_client_header_timeout: '60'
send_timeout: '120' nginx_http_keepalive_timeout: '30 30'
ignore_invalid_headers: 'on' nginx_http_send_timeout: '120'
keepalive_requests: '100' nginx_http_ignore_invalid_headers: 'on'
recursive_error_pages: 'on' nginx_http_keepalive_requests: '100'
sendfile: 'on' nginx_http_recursive_error_pages: 'on'
server_name_in_redirect: 'off' nginx_http_sendfile: 'on'
server_tokens: 'off' nginx_http_server_name_in_redirect: 'off'
tcp_nodelay: 'on' nginx_http_server_tokens: 'off'
tcp_nopush: 'on' nginx_http_tcp_nodelay: 'on'
reset_timedout_connection: 'on' nginx_http_tcp_nopush: 'on'
gzip: 'on' nginx_http_reset_timedout_connection: 'on'
gzip_buffers: '16 8k' nginx_http_gzip: 'on'
gzip_comp_level: '9' nginx_http_gzip_buffers: '16 8k'
gzip_http_version: '1.0' nginx_http_gzip_comp_level: '9'
gzip_min_length: '0' nginx_http_gzip_http_version: '1.0'
gzip_types: 'text/plain text/css application/json application/x-javascript application/javascript text/xml application/xml application/xml+rss text/javascript image/svg+xml' nginx_http_gzip_min_length: '0'
gzip_vary: 'on' nginx_http_gzip_types: 'text/plain text/css application/json application/x-javascript application/javascript text/xml application/xml application/xml+rss text/javascript image/svg+xml'
gzip_disable: '"msie6"' nginx_http_gzip_vary: 'on'
# etag: 'off' nginx_http_gzip_disable: '"msie6"'
#
# Custom global configuration
#
nginx_custom_http: []
#
# Vhosts
#
nginx_vhosts: [] nginx_vhosts: []
nginx_upstreams: []
#
# htpasswd
#
nginx_htpasswd: []
#
# SSL pairs
#
nginx_ssl_pairs: []
#
# Dynamic modules
#
nginx_dyn_modules: []
#
# Diffie-Hellman
#
nginx_dh: null
nginx_dh_path: '{{ nginx_ssl_dir }}/dhparam.pem'
nginx_dh_length: 2048
# Extra
# Note:
# - On Debian, if you use Owncloud from Upstream repository, you must set this var to "/var/www/owncloud"
# - TODO: force this var in vars/FreeBSD.yml
nginx_owncloud_root: '/usr/share/owncloud'

41
doc/auth.md Normal file
View File

@@ -0,0 +1,41 @@
Auth Basic management
=====================
Description
-----------
Auth basic is managed in a separate list. Each auth file can be shared between locations or vhosts.
Each htpasswd has few keys:
- `name`: (M) used to create file and as pointee
- `description`: (M) Used for the message box :)
- `users`: each users is composed with 3 keys: `name` (M), `password` (M) and `state` (O) present/absent (default: present)
- `state`: (O) present or absent. Default: present
`nginx_htpasswd` should be placed in a vault file.
Example
-------
```yaml
nginx_vhosts:
# htpasswd on all vhost
- name: test.local
htpasswd: 'hello'
template: '_base'
# htpasswd only in /hello
- name: test-location.local
template: '_base'
location:
'/hello':
- htpasswd: 'hello'
nginx_htpasswd:
- name: 'hello'
description: 'Please login!'
users:
- name: 'bob'
password: 'my_pass'
```

4
doc/freebsd.md Normal file
View File

@@ -0,0 +1,4 @@
Freebsd
=======
Due to Ansible + FreeBSD limitations (`ansible_processor_vcpus`), You must explicitely set `nginx_worker_processes`.

18
doc/php.md Normal file
View File

@@ -0,0 +1,18 @@
PHP
===
- `nginx_php56` and `nginx_php70`: boolean if you need to preconfigure PHP (default: false)
- `nginx_php##_sockets`: list of sockets (see bellow)
You should see [Nginx upstream module doc](http://nginx.org/en/docs/http/ngx_http_upstream_module.html).
Each socket have:
- `unix_socket`
- `host`
- `port`
- `weight`
- `max_fails`
- `fail_timeout`
With default configuration, it works fine with PHP-FPM.

77
doc/ssl.md Normal file
View File

@@ -0,0 +1,77 @@
SSL/TLS Management
==================
You can put all this variables in a separated vault file.
Variables
---------
- `nginx_dh`: DH content
- `nginx_dh_length`: DH key length (default is 2048)
- `nginx_dh_path`: file localation
- `nginx_ssl_dir`: directory where you install your SSL/TLS keys
- `nginx_ssl_pairs`
Cert/Key pairs
--------------
This list have 3 mandatory keys:
- `name`: MUST be unique
- `key`: content of the private key
- `cert`: content of the public key
OR
- `dest_cert`: remote path where certificate is located
- `dest_key`: remote path where key is located
Note: `name` is used to deploy key/cert. With defaults values dans `name` = "foo", key is -> /etc/nginx/ssl/foo/foo.key
Tips
----
- Deploying key/cert is not mandatory with this role. You can manage it in other place ([letsencrypt](https://letsencrypt.org/)? :)). You just need to set `dest_cert` and `dest_key`!
- In `nginx_vhosts`, `ssl_name` is mandatory. This role will search in `nginx_ssl_pairs` with vhost `name` (first in list if it's a list).
Diffie-Hellman
--------------
If you do not specify any dh param, this role auto generates it.
Example
-------
```yaml
nginx_vhosts;
- name: 'test-ssl.local'
proto: ['http', 'https']
template: '_base'
ssl_name: 'mysuperkey'
- name: 'test-ssl2.local'
proto: ['http', 'https']
template: '_base'
nginx_ssl_pairs:
- name: mysuperkey
key: |
-----BEGIN RSA PRIVATE KEY-----
....(snip)....
-----END RSA PRIVATE KEY-----
cert: |
-----BEGIN CERTIFICATE-----
....(snip)....
-----END CERTIFICATE-----
- name: test-ssl2.local
key: |
-----BEGIN RSA PRIVATE KEY-----
....(snip)....
-----END RSA PRIVATE KEY-----
cert: |
-----BEGIN CERTIFICATE-----
....(snip)....
-----END CERTIFICATE-----
```

43
doc/upstream.md Normal file
View File

@@ -0,0 +1,43 @@
Upstream management
===================
`nginx_upstreams`: List of dict. An upstream has few keys. See bellow.
Note: Few params are unavailable on old Nginx version. But this role do _not_ put it if your version is too old!
Upstream params
---------------
- `name`: upstream name. Can be use in vhost with *proxy_pass http://upstream_name*
- `params`: list of param (hash, zone...)
- `servers`: each upstream MUST have at least 1 server
- `state`: Optional. Can be 'absent' or 'present'
Server params
-------------
You must set a `path`. For example: *192.168.0.50:8080* or *unix:/tmp/my.sock*.
All this params are optional. You should see [Nginx upstream doc](http://nginx.org/en/docs/http/ngx_http_upstream_module.html).
- `weight`
- `max_fails`
- `fail_timeout`
- `backup`
- `down`
- `route`
- `slow_start`
Example
-------
```yaml
nginx_upstreams:
- name: 'proxy_apache'
servers:
- path: '127.0.0.1:80'
max_conns: 150
weight: 10
down: false
state: 'present'
```

73
doc/vhost.md Normal file
View File

@@ -0,0 +1,73 @@
Vhost management
================
You can see many examples in: [tests/test.yml](../tests/test.yml).
`nginx_vhosts`: List of dict. A vhost has few keys. See bellow.
Common
------
- `name`: (M) Domain or list of domain used.
- `template`: (D) template used to create vhost. Optional if you set `delete` to true or using `redirect_tor`.
- `filename`: (O) Specify filename in /etc/nginx/sites-*. Do NOT specify default (reserved keyword). It will be used for log filenames and directories creation.
- `state`: (O) Vhost status. Can be "present" (default), "absent" and "disabled".
- `redirect_from`: (O) Domain list to redirect to the first `name`. You can use this key to redirect non-www to www
- `redirect_to`: (O) Redirect all requests to this domain. Please set scheme (http:// or https:// or $sheme).
- `headers`: (O) Set additionals header as key/value list. You can append "always" to the value. Show [nginx doc](http://nginx.org/en/docs/http/ngx_http_headers_module.html).
- `redirect_to_code`: Redirect code (default: 302)
- `redirect_https`: (O) Boolean. Redirect HTTP to HTTPS. If "true", you _MUST_ set `proto` to ```['https']```.
- `location`: (O) Add new custom locations (it does not overwrite!)
- `location_order`: (O) Due to non preditive `location` order, you can provide the good order (see test-location.local in [tests/test.yml](../tests/test.yml)).
- `more`: (O) Add more custom infos.
- `upstream_params`: (O) Add upstream params (useful when you want to pass variables to PHP)
- `override_try_files`: (O) overrides default try\_files defined in template
- `manage_local_content`: (O) Boolean. Set to false if you do not want to manage local content (images, css...). This option is useless if you use `_proxy` template or `redirect_to` feature.
- `htpasswd`: (O) References name key in `nginx_htpasswd`. Enable auth basic on all vhost. Set "false" to disable.
- `proto`: (O) list of protocol used. Default is a list with "http". If you need http and https, you must set a list with "http" and "https". You can only set "https" without http support.
- `ssl_name`: (D) name of the key used when using TLS/SSL. Optional when `proto` contains "https". If you don't set this value, it will search by `name`.
- `ssl_template` (O) "strong" (default) or "legacy". You can disable SSL helpers and add your own directives by setting "false".
- `php_version` (O) Sepecify PHP version (5 or 7)
- `http_proxy_protocol_port` (O) Enable proxy protocol on http port.
- `https_proxy_protocol_port` (O) Enable proxy protocol on https port.
(O): Optional
(M): Mandatory
(D): Depends other keys...
Templates
---------
- `_base`: static template
- `_backuppc`: access to [BackupPC](http://backuppc.sourceforge.net/) (be careful: you need to install [fcgiwrap](https://packages.debian.org/jessie/fcgiwrap))
- `_dokuwiki`
- `_redirect`: should not be called explicitly
- `_nagios3`: access to Nagios3 (be careful: you need to install [fcgiwrap](https://packages.debian.org/jessie/fcgiwrap))
- `_owncloud`: access to Owncloud (note: you must set `nginx_apt_package` to //nginx-extras//) **UNSTABLE**
- `_phalcon`: Phalcon PHP Framework
- `_php`: PHP base template. Can work with many frameworks/tools
- `_php_index`: Same as above. But you can only run index.php
- `_proxy`
- `_wordpress`
Templates works as parent-child.
About proxy template
--------------------
Proxy template allow you to use Nginx as reverse proxy. Usefull when you have an application service such as Redmine, Jenkins...
You have many key added to vhost key:
- `upstream_name`: (O) upstream name used to pass proxy
- `proxy_params`: (M) list of raw params passed to the vhost
(O) : Optional
Default vhosts
--------------
You can manage default vhost by setting domain name to these variables.
- `nginx_default_vhost`
- `nginx_default_vhost_ssl`

View File

@@ -1 +0,0 @@
<h1>HTML works</h1>

View File

@@ -1,3 +0,0 @@
<?php
echo "<h1>PHP works!</h1>";

View File

@@ -1,4 +1,13 @@
--- ---
# Reload wrapper
- name: reload nginx - name: reload nginx
action: service name=nginx state=reloaded enabled=yes command: nginx -t
notify: real-reload nginx
- name: real-reload nginx
service: name=nginx state=reloaded
- name: restart nginx freebsd
service: name=nginx state=restarted
when: ansible_distribution == "FreeBSD"

View File

@@ -4,13 +4,23 @@ galaxy_info:
description: Nginx for Debian description: Nginx for Debian
company: company:
license: GPLv2 license: GPLv2
min_ansible_version: 1.6 min_ansible_version: 2.0
platforms: platforms:
- name: Debian - name: Debian
versions: versions:
- wheezy
- jessie - jessie
categories: - name: FreeBSD
versions:
- 10.2
galaxy_tags:
- web - web
- proxy
- http
- http2
- https
- ssl
- tls
- nginx
- cdn
dependencies: [] dependencies: []

34
tasks/config.yml Normal file
View File

@@ -0,0 +1,34 @@
---
- name: TEMPLATE | Deploy nginx.conf
template: >
src=etc/nginx/nginx.conf.j2
dest="{{ nginx_etc_dir }}/nginx.conf"
notify: reload nginx
- name: TEMPLATE | Deploy all helpers
template: >
src={{ item }}
dest={{ nginx_helper_dir }}/{{ item | basename | regex_replace('\.j2$','') }}
with_fileglob: '../templates/etc/nginx/helper/*.j2'
notify: reload nginx
- name: TEMPLATE | Deploy custom http configuration
template: >
src=etc/nginx/conf.d/custom.conf.j2
dest="{{ nginx_etc_dir }}/conf.d/custom.conf"
notify: reload nginx
- name: LINEINFILE | Fix path
lineinfile: >
regexp='{{ item.0.regexp }}'
line='{{ item.0.line }}'
dest='{{ item.1 }}'
with_nested:
-
- regexp: '^fastcgi_param SCRIPT_FILENAME'
line: 'fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;'
- regexp: '^fastcgi_param DOCUMENT_ROOT'
line: 'fastcgi_param DOCUMENT_ROOT $realpath_root;'
- [ '/etc/nginx/fastcgi_params', '/etc/nginx/fastcgi.conf' ]
when: nginx_fastcgi_fix_realpath

16
tasks/dyn_modules.yml Normal file
View File

@@ -0,0 +1,16 @@
---
- name: FAIL | If Dynamic module is not available
fail: msg="{{ item }} dynamic module is not available"
with_items: "{{ nginx_dyn_modules }}"
when: "'{{ item }}=dynamic' not in nginx_modules"
- name: APT | Install nginx modules
apt: >
pkg="libnginx-mod-{{ item | replace('_', '-') }}"
state=present
default_release={{ ansible_distribution_release + '-backports' if nginx_backports else ansible_distribution_release }}
with_items: "{{ nginx_dyn_modules }}"
when: ansible_distribution == 'Debian'
# TODO: manage freebsd

20
tasks/htpasswd.yml Normal file
View File

@@ -0,0 +1,20 @@
---
- name: FILE | Delete htpasswd file
file: >
path={{ nginx_htpasswd_dir }}/{{ item.name }}
state=absent
with_items: "{{ nginx_htpasswd }}"
when: item.state is defined and item.state == 'absent'
- name: HTPASSWD | Manage files
htpasswd: >
name={{ item.1.name }}
password={{ item.1.password }}
state={{ item.1.state | default('present') }}
path={{ nginx_htpasswd_dir }}/{{ item.0.name }}
with_subelements:
- "{{ nginx_htpasswd }}"
- users
when: item.0.state is not defined or item.0.state == 'present'
no_log: true

23
tasks/install_Debian.yml Normal file
View File

@@ -0,0 +1,23 @@
---
- name: APT | Update cache
apt: >
update_cache=yes
cache_valid_time=3600
changed_when: false
- name: APT | Force OpenSSL from backports (fix dependency break)
apt: >
pkg=openssl
state=latest
default_release={{ ansible_distribution_release + '-backports' }}
when: nginx_backports
- name: APT | Install nginx and dependencies
apt: >
pkg={{ nginx_apt_package }}
state=present
default_release={{ ansible_distribution_release + '-backports' if nginx_backports else ansible_distribution_release }}
- name: APT | Install python-passlib
apt: pkg=python-passlib state=present

46
tasks/install_FreeBSD.yml Normal file
View File

@@ -0,0 +1,46 @@
---
- name: PKGNG | Install nginx and related tools
pkgng: name={{ item }} state=present
with_items:
- "{{ nginx_pkgng_package }}"
- py27-passlib
- curl
- name: FILE | Create configuration dir (like Debian)
file: path="{{ nginx_etc_dir }}/{{ item }}" state=directory
with_items:
- conf.d
- sites-available
- sites-enabled
- name: STAT | Check fastcgi.conf
stat: path={{ nginx_etc_dir }}/fastcgi.conf
register: conf
- name: COPY | config
command: "cp {{ nginx_etc_dir }}/fastcgi_params {{ nginx_etc_dir }}/fastcgi.conf"
when: not conf.stat.exists
notify: reload nginx
- name: LINEINFILE | Add fastcgi config
lineinfile: >
line="fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;"
dest="{{ nginx_etc_dir }}/fastcgi.conf"
notify: reload nginx
- name: COPY | Populate proxy_params
copy: >
content="proxy_set_header Host $http_host;\nproxy_set_header X-Real-IP $remote_addr;\nproxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header X-Forwarded-Proto $scheme;"
dest="{{ nginx_etc_dir }}/proxy_params"
- name: FILE | Create log directory
file: >
path={{ nginx_log_dir }}
owner={{ nginx_user }}
group=wheel
mode=0755
state=directory
- name: SERVICE | Enable nginx
service: name=nginx enabled=yes

View File

@@ -1,44 +1,30 @@
--- ---
- name: APT | Install nginx - name: INCLUDE_VARS | Related to OS
apt: pkg={{ nginx_apt_package }} state=latest update_cache=yes cache_valid_time=3600 include_vars: "{{ ansible_distribution }}.yml"
- name: SHELL | Get Nginx version - name: INCLUDE | Install
shell: nginx -v 2>&1 | sed -r 's#.*/##;' | cut -d ' ' -f 1 include: install_{{ ansible_distribution }}.yml
register: nginx_version
changed_when: false
- name: TEMPLATE | Deploy nginx.conf - name: INCLUDE | Prepare
template: > include: prepare.yml
src=etc/nginx/nginx.conf.j2
dest=/etc/nginx/nginx.conf
notify: reload nginx
- name: FILE | Create /etc/nginx/helpers - name: INCLUDE | Manage dynamic modules
file: dest=/etc/nginx/helpers owner=root mode=0755 state=directory include: dyn_modules.yml
when: nginx_version.stdout | version_compare('1.9.11', 'ge')
- name: FILE | Create /etc/nginx/ssl - name: INCLUDE | Install
file: dest=/etc/nginx/ssl owner=root mode=0755 state=directory include: config.yml
#- name: COMMAND | Creates DH file
# command: openssl dhparam -out {{ nginx_dh_path }} {{ nginx_dh_length }}
# args:
# creates: "{{ nginx_dh_path }}"
- name: TEMPLATE | Deploy all helpers
template: >
src={{ item }}
dest=/etc/nginx/helpers/{{ item | basename | regex_replace('\.j2$','') }}
with_fileglob: '../templates/etc/nginx/helpers/*.j2'
notify: reload nginx
- name: INCLUDE | Upstream configuration - name: INCLUDE | Upstream configuration
include: upstream.yml include: upstream.yml
when: nginx_php
- name: INCLUDE | htpasswd configuration
include: htpasswd.yml
- name: INCLUDE | SSL configuration
include: ssl.yml
- name: INCLUDE | Vhosts configuration - name: INCLUDE | Vhosts configuration
include: vhost.yml include: vhost.yml
# TODO:
# - Python
# - Ruby (SHIT!)

26
tasks/prepare.yml Normal file
View File

@@ -0,0 +1,26 @@
---
- name: SHELL | Get Nginx version
shell: nginx -v 2>&1 | sed -r 's#.*/##;' | cut -d ' ' -f 1
args:
executable: /bin/sh
register: nginx_version
changed_when: false
- name: SHELL | Get module list
shell: nginx -V 2>&1 | tr -- - '\n' | grep -A 1 with | grep _module | sed -r 's/_module//g; s/\s+//g' | sort
args:
executable: /bin/sh
register: shell_modules
changed_when: false
- name: SET_FACT | Save modules
set_fact:
nginx_modules: "{{ shell_modules.stdout_lines }}"
- name: FILE | Create folders
file: dest="{{ item.dir }}" owner="{{ item.owner }}" mode="{{ item.mode }}" state=directory
with_items: "{{ nginx_dirs }}"
- name: FILE | Create ansible facts dir
file: path=/etc/ansible/facts.d state=directory

52
tasks/ssl.yml Normal file
View File

@@ -0,0 +1,52 @@
---
- name: COMMAND | Generate DH file
command: openssl dhparam -out {{ nginx_dh_path }} {{ nginx_dh_length }}
args:
creates: "{{ nginx_dh_path }}"
when: nginx_dh is not string
notify: reload nginx
async: 1000
register: dh
- name: COPY | Deploy DH file from vars
copy: >
content="{{ nginx_dh }}"
dest="{{ nginx_dh_path }}"
when: nginx_dh is string
notify: reload nginx
- name: FILE | Create SSL directories
file: >
path="{{ nginx_ssl_dir + '/' + item.name }}"
state=directory
with_items: "{{ nginx_ssl_pairs }}"
when: item.dest_key is not defined or item.dest_cert is not defined
no_log: true
- name: COPY | Deploy SSL keys
copy: >
content="{{ item.key }}"
dest="{{ nginx_ssl_dir + '/' + item.name + '/' + item.name + '.key' if item.dest_key is not defined else item.dest_key }}"
mode=0640
with_items: "{{ nginx_ssl_pairs }}"
when: item.key is defined
notify: reload nginx
no_log: true
- name: COPY | Deploy SSL certs
copy: >
content="{{ item.cert }}"
dest="{{ nginx_ssl_dir + '/' + item.name + '/' + item.name + '.crt' if item.dest_cert is not defined else item.dest_cert }}"
mode=0644
with_items: "{{ nginx_ssl_pairs }}"
when: item.cert is defined
notify: reload nginx
no_log: true
- name: Check DH command status
async_status: jid={{ dh.ansible_job_id }}
register: job_result
until: job_result.finished
retries: 30
when: nginx_dh is not string

View File

@@ -1,10 +1,29 @@
--- ---
- name: SET_FACT | Backward compatibility with old version of this role
set_fact: >
nginx_php56: true
when: nginx_php is defined and nginx_php
- name: TEMPLATE | Deploy PHP upstream to Nginx - name: TEMPLATE | Deploy PHP upstream to Nginx
template: src=etc/nginx/upstream/php.conf.j2 dest=/etc/nginx/conf.d/php.conf template: >
src=etc/nginx/upstream/php.conf.j2
dest="{{ nginx_etc_dir }}/conf.d/php.conf"
when: nginx_php56 or nginx_php70
notify: reload nginx notify: reload nginx
- name: TEMPLATE | Deploy other upstreams - name: TEMPLATE | Deploy other upstreams
template: src=etc/nginx/upstream/upstream.conf.j2 dest=/etc/nginx/conf.d/upstream-{{ item.name }}.conf template: >
with_items: nginx_upstreams src=etc/nginx/upstream/upstream.conf.j2
dest={{ nginx_etc_dir }}/conf.d/upstream-{{ item.name }}.conf
with_items: "{{ nginx_upstreams }}"
when: item.state is not defined or item.state == 'present'
notify: reload nginx
- name: FILE | Delete other upstreams
file: >
path={{ nginx_etc_dir }}/conf.d/upstream-{{ item.name }}.conf
state=absent
with_items: "{{ nginx_upstreams }}"
when: item.state is defined and item.state == 'absent'
notify: reload nginx notify: reload nginx

View File

@@ -1,65 +1,90 @@
--- ---
- name: FILE | Create root folders (foreach nginx_vhosts) - name: FAIL | Check filenames
fail: msg="Forbidden keyword default on vhost {{ item.name if item.name is string else item.name[0] }}"
when: item.filename is defined and item.filename == 'default'
with_items: "{{ nginx_vhosts }}"
- name: FAIL | Check HTTPS redir and proto
fail: msg="You can't have HTTP proto and HTTPS redirection at the same time"
when: >
((item.proto is defined and 'http' in item.proto) or (item.proto is not defined)) and
(item.redirect_http is defined and item.redirect_http)
with_items: "{{ nginx_vhosts }}"
- name: FILE | Create root directory
file: > file: >
path={{ nginx_root }}/{{ item.name if item.name is string else item.name[0] }}/public path={{ nginx_root }}
state=directory state=directory
owner={{ item.owner | default('www-data') }}
group={{ item.group | default('www-data') }} - name: FILE | Create root public folders (foreach nginx_vhosts)
file: >
path={{ nginx_root }}/{{ item.filename | default(item.name if item.name is string else item.name[0]) }}/public
state=directory
owner={{ item.owner | default(nginx_user) }}
group={{ item.group | default(nginx_user) }}
mode={{ item.mode | default('0755') }} mode={{ item.mode | default('0755') }}
with_items: nginx_vhosts with_items: "{{ nginx_vhosts }}"
when: item.root is not defined and item.template != '_proxy' when: >
item.root is not defined and
(item.template is defined and item.template not in nginx_templates_no_dir) and
(item.state is not defined or not item.state != 'absent') and
item.redirect_to is not defined
- name: TEMPLATE | Create vhosts - name: TEMPLATE | Create vhosts
template: > template: >
src=etc/nginx/sites-available/{{ item.template }}.j2 src=etc/nginx/sites-available/{{ item.template if item.redirect_to is not defined else '_redirect' }}.j2
dest=/etc/nginx/sites-available/{{ item.name if item.name is string else item.name[0] }} dest={{ nginx_etc_dir }}/sites-available/{{ item.filename | default(item.name if item.name is string else item.name[0]) }}
with_items: nginx_vhosts with_items: "{{ nginx_vhosts }}"
notify: reload nginx notify: ['reload nginx', 'restart nginx freebsd']
when: item.delete is not defined or not item.delete when: item.state is not defined or item.state != 'absent'
#- name: COPY | Add index.html / index.php
# copy: src={{ item }} dest={{ nginx_root }}/{{ item.name }}/public/{{ item }} owner=www-data group=www-data mode=0666
# with_fileglob: "web/*"
- name: FILE | Delete vhosts - name: FILE | Delete vhosts
file: dest=/etc/nginx/sites-enabled/{{ item.name if item.name is string else item.name[0] }} state=absent file: path={{ nginx_etc_dir }}/{{ item.1 }}/{{ item.0.filename | default(item.0.name if item.0.name is string else item.0.name[0]) }} state=absent
file: dest=/etc/nginx/sites-available/{{ item.name if item.name is string else item.name[0] }} state=absent with_nested:
with_items: nginx_vhosts - "{{ nginx_vhosts }}"
notify: reload nginx - ['sites-available', 'sites-enabled']
when: item.delete is defined and item.delete notify: ['reload nginx', 'restart nginx freebsd']
when: item.state is defined and item.state == 'absent'
- name: FILE | Enable vhosts - name: FILE | Enable vhosts
file: > file: >
src=/etc/nginx/sites-available/{{ item.name if item.name is string else item.name[0] }} src={{ nginx_etc_dir }}/sites-available/{{ item.filename | default(item.name if item.name is string else item.name[0]) }}
dest=/etc/nginx/sites-enabled/{{ item.name if item.name is string else item.name[0] }} dest={{ nginx_etc_dir }}/sites-enabled/{{ item.filename | default(item.name if item.name is string else item.name[0]) }}
state=link state=link
with_items: nginx_vhosts with_items: "{{ nginx_vhosts }}"
notify: reload nginx notify: ['reload nginx', 'restart nginx freebsd']
when: > when: >
((item.enable is not defined) or item.state is not defined or item.state == 'present'
(item.enable is defined and item.enable)) and
(item.delete is not defined or not item.delete)
- name: FILE | Disable vhosts - name: FILE | Disable vhosts
file: dest=/etc/nginx/sites-enabled/{{ item.name if item.name is string else item.name[0] }} state=absent file: path={{ nginx_etc_dir}}/sites-enabled/{{ item.filename | default(item.name if item.name is string else item.name[0]) }} state=absent
with_items: nginx_vhosts with_items: "{{ nginx_vhosts }}"
notify: reload nginx notify: ['reload nginx', 'restart nginx freebsd']
when: item.enable is defined and not item.enable when: item.state is defined and item.state == 'disabled'
#- name: FILE | Create ssl dir per vhost (if needed) - name: FILE | Delete default vhost when explicitely defined
# file: dest=/etc/nginx/ssl/{{ item.name }} owner=root mode=0750 state=directory file: >
# with_items: nginx_vhosts path={{ nginx_etc_dir }}/sites-enabled/default
# when: item.ssl.use is defined and item.ssl.use state=absent
notify: ['reload nginx', 'restart nginx freebsd']
when: nginx_default_vhost is not none
# TODO... - name: FILE | Auto set default vhost
#- name: COPY | Deploy SSL keys if needed file: >
# copy: src=keys/{{ item.name }}/{{ item.name }}.crt dest=/etc/nginx/ssl/{{ item.name }} mode=660 src={{ nginx_etc_dir }}/sites-available/default
# copy: src=keys/{{ item.name }}/{{ item.name }}.key dest=/etc/nginx/ssl/{{ item.name }} mode=660 dest={{ nginx_etc_dir }}/sites-enabled/default
# with_items: nginx_vhosts state=link
# when: item.ssl.use and not generatekey notify: ['reload nginx', 'restart nginx freebsd']
when: nginx_default_vhost is none
# TODO: - name: TEMPLATE | Deploy facts
# - deploy defaults files (index.html/index.php) allready in files/ template:
# - work with role "ssl_autosign" src=etc/ansible/facts.d/nginx.fact.j2
dest=/etc/ansible/facts.d/nginx.fact
mode=0644
register: fact
- name: SETUP
action: setup
when: fact.changed

View File

@@ -0,0 +1,4 @@
{
"fact_nginx_vhosts":
{{ nginx_vhosts | to_nice_json(indent=8) }}
}

View File

@@ -0,0 +1,7 @@
#
# {{ ansible_managed }}
#
{% for i in nginx_custom_http %}
{{ i }}
{% endfor %}

View File

@@ -0,0 +1,18 @@
#
# {{ ansible_managed }}
#
ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH:ECDHE-RSA-AES128-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA128:DHE-RSA-AES128-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES128-GCM-SHA128:ECDHE-RSA-AES128-SHA384:ECDHE-RSA-AES128-SHA128:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES128-SHA128:DHE-RSA-AES128-SHA128:DHE-RSA-AES128-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA384:AES128-GCM-SHA128:AES128-SHA128:AES128-SHA128:AES128-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4";
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains"{% if nginx_version.stdout | version_compare('1.7.5', 'ge') %} always{% endif %};
{% if nginx_version.stdout | version_compare('1.3.7', 'ge') %}
ssl_stapling on;
ssl_stapling_verify on;
{% endif %}
resolver {{ nginx_resolver_hosts | join(' ') }} valid={{ nginx_resolver_valid }};
resolver_timeout {{ nginx_resolver_timeout }};
ssl_dhparam {{ nginx_dh_path }};
# vim:filetype=nginx

View File

@@ -0,0 +1,18 @@
#
# {{ ansible_managed }}
#
ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains"{% if nginx_version.stdout | version_compare('1.7.5', 'ge') %} always{% endif %};
{% if nginx_version.stdout | version_compare('1.3.7', 'ge') %}
ssl_stapling on;
ssl_stapling_verify on;
{% endif %}
resolver {{ nginx_resolver_hosts | join(' ') }} valid={{ nginx_resolver_valid }};
resolver_timeout {{ nginx_resolver_timeout }};
ssl_dhparam {{ nginx_dh_path }};
# vim:filetype=nginx

View File

@@ -1,18 +0,0 @@
#
# {{ ansible_managed }}
#
ssl_ciphers "ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4";
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains";
add_header X-Frame-Options DENY;
add_header X-Content-Type-Options nosniff;
ssl_stapling on;
ssl_stapling_verify on;
resolver {{ nginx_resolver.hosts | default(['208.67.222.222', '208.67.220.220']) | join(' ') }} valid={{ nginx_resolver.valid}}s;
resolver_timeout {{ nginx_resolver.timeout }}s;
# vim:filetype=nginx

View File

@@ -1,18 +0,0 @@
#
# {{ ansible_managed }}
#
ssl_ciphers "AES256+EECDH:AES256+EDH";
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains";
add_header X-Frame-Options DENY;
add_header X-Content-Type-Options nosniff;
ssl_stapling on;
ssl_stapling_verify on;
resolver {{ nginx_resolver.hosts | default(['208.67.222.222', '208.67.220.220']) | join(' ') }} valid={{ nginx_resolver.valid}}s;
resolver_timeout {{ nginx_resolver.timeout }}s;
# vim:filetype=nginx

View File

@@ -5,26 +5,53 @@
user {{ nginx_user }}; user {{ nginx_user }};
worker_processes {{ nginx_worker_processes }}; worker_processes {{ nginx_worker_processes }};
pid {{ nginx_pid }}; pid {{ nginx_pid }};
{% if nginx_version.stdout | version_compare('1.9.11', 'ge') %}
{% for module in nginx_dyn_modules -%}
load_module "modules/ngx_{{ module }}_module.so";
{% endfor %}
{% endif %}
events { events {
{% for key, value in nginx_events.iteritems() %} worker_connections {{ nginx_events_worker_connections }};
{{ "\t%-30s %s" | format(key, value) }}; multi_accept {{ nginx_events_multi_accept }};
{% endfor %} use {{ nginx_events_use }};
} }
http { http {
types_hash_max_size 2048; types_hash_max_size {{ nginx_http_types_hash_max_size }};
include /etc/nginx/mime.types; include {{ nginx_etc_dir }}/mime.types;
default_type application/octet-stream;
# From Ansible default_type {{ nginx_http_default_type }};
{% for key, value in nginx_http.iteritems() %} access_log {{ nginx_http_access_log }};
{{ "\t%-30s %s" | format(key, value) }}; error_log {{ nginx_http_error_log }};
{% endfor %} client_body_buffer_size {{ nginx_http_client_body_buffer_size }};
# /From Ansible client_header_buffer_size {{ nginx_http_client_header_buffer_size }};
client_max_body_size {{ nginx_http_client_max_body_size }};
large_client_header_buffers {{ nginx_http_large_client_header_buffers }};
client_body_timeout {{ nginx_http_client_body_timeout }};
client_header_timeout {{ nginx_http_client_header_timeout }};
keepalive_timeout {{ nginx_http_keepalive_timeout }};
send_timeout {{ nginx_http_send_timeout }};
ignore_invalid_headers {{ nginx_http_ignore_invalid_headers }};
keepalive_requests {{ nginx_http_keepalive_requests }};
recursive_error_pages {{ nginx_http_recursive_error_pages }};
sendfile {{ nginx_http_sendfile }};
server_name_in_redirect {{ nginx_http_server_name_in_redirect }};
server_tokens {{ nginx_http_server_tokens }};
tcp_nodelay {{ nginx_http_tcp_nodelay }};
tcp_nopush {{ nginx_http_tcp_nopush }};
reset_timedout_connection {{ nginx_http_reset_timedout_connection }};
gzip {{ nginx_http_gzip }};
gzip_buffers {{ nginx_http_gzip_buffers }};
gzip_comp_level {{ nginx_http_gzip_comp_level }};
gzip_http_version {{ nginx_http_gzip_http_version }};
gzip_min_length {{ nginx_http_gzip_min_length }};
gzip_types {{ nginx_http_gzip_types }};
gzip_vary {{ nginx_http_gzip_vary }};
gzip_disable {{ nginx_http_gzip_disable }};
include /etc/nginx/conf.d/*.conf; include {{ nginx_etc_dir }}/conf.d/*.conf;
include /etc/nginx/sites-enabled/*; include {{ nginx_etc_dir }}/sites-enabled/*;
} }
# vim:filetype=nginx # vim:filetype=nginx

View File

@@ -0,0 +1,33 @@
{% extends "_base.j2" %}
{% block root %}
root /usr/share/backuppc/cgi-bin;
{% endblock %}
{% block template_try_files %}
{% endblock %}
{% block template_index %}
index index.cgi;
{% endblock %}
{% block template_local_content %}
location ~ /\.ht {
deny all;
}
location /backuppc/image {
alias /usr/share/backuppc/image;
expires 60d;
}
{% endblock %}
{% block template_upstream_location %}
location ~ \.cgi$ {
gzip off;
include {{ nginx_etc_dir }}/fastcgi_params;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
fastcgi_index BackupPC_Admin;
fastcgi_param SCRIPT_FILENAME /usr/share/backuppc/cgi-bin$fastcgi_script_name;
}
{% endblock %}

View File

@@ -1,6 +1,27 @@
{% set __listen = item.listen | default(['80']) %} {% set __proto = item.proto | default(['http']) %}
{% set __listen_ssl = item.listen_ssl | default(['443']) %} {% set __main_name = item.filename | default(item.name if item.name is string else item.name[0]) %}
{% set __listen = item.listen | default([80]) %}
{% set __listen_ssl = item.listen_ssl | default([443]) %}
{% set __http_proxy_protocol_port = item.http_proxy_protocol_port | default([]) %}
{% set __https_proxy_protocol_port = item.https_proxy_protocol_port | default([]) %}
{% set __location = item.location | default({}) %} {% set __location = item.location | default({}) %}
{% set __headers = item.headers | default(nginx_servers_default_headers) %}
{% set __ssl_name = item.ssl_name | default(item.name if item.name is string else item.name[0]) %}
{% set __location_order = item.location_order | default(__location.keys()) %}
{% macro htpasswd(htpasswd_name, indent=1) -%}
{%- if htpasswd_name != false %}
{%- for ht in nginx_htpasswd if ht.name == htpasswd_name %}
{{ "\t" * indent }}auth_basic "{{ ht.description }}";
{{ "\t" * indent }}auth_basic_user_file {{ nginx_htpasswd_dir }}/{{ ht.name }};
{%- endfor %}
{%- endif %}
{%- endmacro %}
{% macro ssl(ssl_name) %}
{% for sn in nginx_ssl_pairs if sn.name == ssl_name %}
ssl_certificate {{ nginx_ssl_dir + '/' + ssl_name + '/' + ssl_name + '.crt' if sn.dest_cert is not defined else sn.dest_cert }};
ssl_certificate_key {{ nginx_ssl_dir + '/' + ssl_name + '/' + ssl_name + '.key' if sn.dest_key is not defined else sn.dest_key }};
{% endfor %}
{%- endmacro %}
# #
# {{ ansible_managed }} # {{ ansible_managed }}
# #
@@ -9,24 +30,51 @@
# HTTP # HTTP
# #
server { server {
{% if 'http' in __proto %}
{% for port in __listen %} {% for port in __listen %}
listen {{ port }}; listen {{ port }}{% if nginx_default_vhost == __main_name %} default_server{% endif %}{% if port | int in __http_proxy_protocol_port %} proxy_protocol{% endif %};
{% endfor %} {% endfor %}
server_name {% if item.name is string %}{{ item.name }}{% else %}{{ item.name | join(' ') }}{% endif %}; {% endif %}
{% if 'https' in __proto %}
{% for port in __listen_ssl %}
listen {{ port }}{% if nginx_default_vhost_ssl == __main_name %} default_server{% endif %} ssl{% if nginx_auto_config_httpv2 and 'http_v2' in nginx_modules %} http2{% endif %}{% if port | int in __https_proxy_protocol_port %} proxy_protocol{% endif %};
{% endfor %}
{{ ssl(__ssl_name) }}
{% if item.ssl_template is not defined or item.ssl_template != false %}
include {{ nginx_helper_dir + '/ssl-' + item.ssl_template | default('strong') }};
{% endif %}
{% endif %}
server_name {% if item.name is string %}{{ item.name }}{% else %}{{ "\n\t\t" }}{{ item.name | join("\n\t\t") }}{% endif %};
{% block root %}
{% if item.root is defined %} {% if item.root is defined %}
root {{ item.root }}; root {{ item.root }};
{% else %} {% else %}
root {{ nginx_root }}/{{ item.name if item.name is string else item.name[0] }}/public; root {{ nginx_root }}/{{ __main_name }}/public;
{% endif %} {% endif %}
{% endblock %}
{% block template_index %} {% block template_index %}
index {{ item.index | default('index.html index.htm') }}; index {{ item.index | default('index.html index.htm') }};
{% endblock %} {% endblock %}
{% block template_more %}
{% if item.more is defined and item.more is iterable %} {% if item.more is defined and item.more is iterable %}
{% for line in item.more %} {% for line in item.more %}
{{ line }} {{ line }}
{% endfor %} {% endfor %}
{% endif %} {% endif %}
{% endblock %}
{% if item.htpasswd is defined %}
{{ htpasswd(item.htpasswd, 1) }}
{% endif %}
{% block template_headers %}
# --> Custom headers
{% for key, value in __headers.iteritems() %}
add_header {{ key }} "{{ value | replace(' always', '') }}"{% if nginx_version.stdout | version_compare('1.7.5', 'ge') and ' always' in value %} always{% endif %};
{% endfor %}
# <-- Custom headers
{% endblock %}
{% if not __location.has_key('/') %} {% if not __location.has_key('/') %}
location / { location / {
@@ -41,12 +89,26 @@ server {
{% block template_custom_location %} {% block template_custom_location %}
{% endblock %} {% endblock %}
{% if __location_order | length > 0 %}
# --> Custom locations
{% for location in __location_order %}
location {{ location }} {
{% set opts = __location[location] %}
{% for opt in opts %}
{% if opt.htpasswd is defined %}{{ htpasswd(opt.htpasswd, 2) }}{% else %}
{{ opt }}
{% endif %}
{% endfor %}
}
{% endfor %} # <-- Custom locations
{% endif %}
{% block template_local_content %}
{% if item.manage_local_content is not defined or item.manage_local_content %}
location ~ /\.ht { location ~ /\.ht {
deny all; deny all;
} }
{% block template_local_content %}
{% if item.manage_local_content is not defined or item.manage_local_content %}
location = /favicon.ico { location = /favicon.ico {
expires 30d; expires 30d;
access_log off; access_log off;
@@ -60,51 +122,46 @@ server {
{% endif %} {% endif %}
{% endblock %} {% endblock %}
{% if __location is iterable and __location | length > 0 %} {% if item.use_access_log is defined %}
# --> Custom locations {% if item.use_access_log %}
{% for location, opts in __location.iteritems() %} access_log {{ nginx_log_dir }}/{{ __main_name }}_access.log combined;
location {{ location }} {
{% for opt in opts %}
{{ opt }}
{% endfor %}
}
{% endfor %} # <-- Custom locations
{% endif %}
{% if item.use_access_log is defined and item.use_access_log %}
access_log {{ nginx_log_dir }}/{{ item.name[0] }}_access.log combined;
{% else %} {% else %}
access_log off; access_log off;
{% endif %} {% endif %}
{% if item.use_error_log is defined and item.use_error_log %} {% endif %}
error_log {{ nginx_log_dir }}/{{ item.name[0] }}_error.log {{ nginx_error_log_level }}; {% if item.use_error_log is defined %}
{% if item.use_error_log %}
error_log {{ nginx_log_dir }}/{{ __main_name }}_error.log {{ nginx_error_log_level }};
{% else %} {% else %}
error_log off; error_log off;
{% endif %} {% endif %}
{% endif %}
} }
{# {% if item.redirect_https is defined and item.redirect_https %}
ssl on; #
ssl_certificate {{ nginx_ssl_dir }}/{{ item.name }}/{{ item.name }}.crt; # Redirect HTTP to HTTPS
ssl_certificate_key {{ nginx_ssl_dir }}/{{ item.name }}/{{ item.name }}.key; #
include /etc/nginx/helpers/ssl-{{ item.ssl.template | default('strong') }}; server {
#} {% for port in __listen %}
listen {{ port }}{% if nginx_default_vhost == __main_name %} default_server{% endif %}{% if port | int in __http_proxy_protocol_port %} proxy_protocol{% endif %};
{% endfor %}
server_name {% if item.name is string %}{{ item.name }}{% else %}{{ "\n\t\t" }}{{ item.name | join("\n\t\t") }}{% endif %};
return 301 https://{{ __main_name }}{% if '443' not in __listen_ssl %}:{{ __listen_ssl[0] }}{% endif %}$request_uri;
}
{% endif %}
# HTTPS
#server {
#}
{% if item.redirect_from is defined and item.redirect_from is iterable %} {% if item.redirect_from is defined and item.redirect_from is iterable %}
# #
# Redirect from # Redirect from
# #
server { server {
{% for port in __listen %} {% for port in __listen %}
listen {{ port }}; listen {{ port }}{% if port | int in __http_proxy_protocol_port %} proxy_protocol{% endif %};
{% endfor %} {% endfor %}
server_name {{ item.redirect_from | join(' ') }}; server_name {% if item.redirect_from is string %}{{ item.redirect_from }}{% else %}{{ "\n\t\t" }}{{ item.redirect_from | join("\n\t\t") }}{% endif %};
return 301 $scheme://{{ item.name[0] }}$request_uri; return 301 $scheme://{{ __main_name }}$request_uri;
} }
{% endif %} {% endif %}

View File

@@ -0,0 +1,67 @@
{% extends "_php.j2" %}
{% block root %}
root {{ nginx_nagios_root }};
{% endblock %}
{% block template_try_files %}
{% endblock %}
{% block template_index %}
index index.php index.html;
{% endblock %}
{% block template_headers %}
# --> Custom headers
{% for key, value in __headers.iteritems() %}
{% if key == "X-Frame-Options" %}
# X-Frame-Options forced by Ansible
add_header {{ key }} "SAMEORIGIN"{% if nginx_version.stdout | version_compare('1.7.5', 'ge') %} always{% endif %};
{% else %}
add_header {{ key }} "{{ value | replace(' always', '') }}"{% if nginx_version.stdout | version_compare('1.7.5', 'ge') and ' always' in value %} always{% endif %};
{% endif %}
{% endfor %}
# <-- Custom headers
{% endblock %}
{% block template_local_content %}
location ~ /\.ht {
deny all;
}
location /stylesheets {
{% if nginx_nagios_stylesheets is defined %}
alias {{ nginx_nagios_stylesheets }};
{% endif %}
expires 60d;
}
{% endblock %}
{% block template_upstream_location %}
{% if ansible_distribution == 'Debian' %}
location /cgi-bin/nagios3 {
root /usr/lib;
{% elif ansible_distribution == 'FreeBSD' %}
location /cgi-bin {
{% endif %}
try_files $uri =404;
{% if nginx_version.stdout | version_compare('1.6.1', 'lt') %}
include fastcgi_params;
{% else %}
include fastcgi.conf;
{% endif %}
fastcgi_pass unix:{{ nginx_fcgiwrap_sock }};
fastcgi_param AUTH_USER $remote_user;
fastcgi_param REMOTE_USER $remote_user;
}
location ~ \.php$ {
fastcgi_pass {{ php_upstream }};
fastcgi_index index.php;
{% if nginx_version.stdout | version_compare('1.6.1', 'lt') %}
include fastcgi_params;
{% else %}
include fastcgi.conf;
{% endif %}
}
{% endblock %}

View File

@@ -0,0 +1,87 @@
{% extends "_php.j2" %}
{% block root %}
root {{ nginx_owncloud_root }};
{% endblock %}
{% block template_index %}
index index.php;
{% endblock %}
{% block template_more %}
error_page 403 /core/templates/403.php;
error_page 404 /core/templates/404.php;
gzip off;
client_max_body_size 10G;
fastcgi_buffers 64 4K;
rewrite ^/caldav(.*)$ /remote.php/caldav$1 redirect;
rewrite ^/carddav(.*)$ /remote.php/carddav$1 redirect;
rewrite ^/webdav(.*)$ /remote.php/webdav$1 redirect;
{% endblock %}
{% block template_headers %}
add_header X-XSS-Protection "1; mode=block";
add_header X-Robots-Tag none;
add_header X-Content-Type-Options nosniff;
add_header X-Download-Options noopen;
add_header X-Permitted-Cross-Domain-Policies none;
add_header X-Frame-Options SAMEORIGIN;
{% endblock %}
{% block template_try_files %}
try_files $uri $uri/ =404;
{% endblock %}
{% block template_upstream_location %}
location ~ /remote.php {
dav_methods PUT DELETE MKCOL COPY MOVE;
dav_ext_methods PROPFIND OPTIONS;
fastcgi_pass {{ php_upstream }};
fastcgi_param HOME {{ nginx_owncloud_root }};
fastcgi_param HTTP_HOME {{ nginx_owncloud_root }};
fastcgi_param PATH /usr/local/bin:/usr/bin:/bin;
fastcgi_param modHeadersAvailable true;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
{% if nginx_version.stdout | version_compare('1.6.1', 'lt') %}
include fastcgi_params;
{% else %}
include fastcgi.conf;
{% endif %}
}
location ~ \.php(?:$|/) {
fastcgi_pass {{ php_upstream }};
fastcgi_index index.php;
fastcgi_param HOME {{ nginx_owncloud_root }};
fastcgi_param HTTP_HOME {{ nginx_owncloud_root }};
fastcgi_param PATH /usr/local/bin:/usr/bin:/bin;
fastcgi_param modHeadersAvailable true;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
{% if nginx_version.stdout | version_compare('1.6.1', 'lt') %}
include fastcgi_params;
{% else %}
include fastcgi.conf;
{% endif %}
}
{% endblock %}
{% block template_local_content %}
location ~* \.(?:css|js)$ {
try_files $uri /index.php$is_args$args;
expires 2h;
}
location ~* \.(?:jpg|jpeg|gif|bmp|ico|png|swf)$ {
expires 2d;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location ~ ^/(?:\.ht|data|config|db_structure\.xml|README){
deny all;
}
{% endblock %}

View File

@@ -1,4 +1,24 @@
{% extends "_base.j2" %} {% extends "_base.j2" %}
{% macro phpv(version) %}
{% if version == 56 or version == "56" or version == "5.6" %}
{{ nginx_upstream_php56 -}}
{% elif version == 70 or version == "70" or version == "7.0" %}
{{ nginx_upstream_php70 -}}
{% else %}
{# Hack... define another upstream #}
{{ version -}}
{% endif %}
{%- endmacro -%}
{% if item.php_version is defined %}
{% set php_upstream = phpv(item.php_version) %}
{% elif nginx_php56 %}
{% set php_upstream = phpv(56) %}
{% elif nginx_php70 %}
{% set php_upstream = phpv(70) %}
{% endif %}
{% block template_index %} {% block template_index %}
index {{ item.index | default('index.html index.htm index.php') }}; index {{ item.index | default('index.html index.htm index.php') }};
{% endblock %} {% endblock %}
@@ -9,7 +29,7 @@
{% block template_upstream_location %} {% block template_upstream_location %}
location ~ \.php$ { location ~ \.php$ {
fastcgi_pass php; fastcgi_pass {{ php_upstream }};
fastcgi_index index.php; fastcgi_index index.php;
{% if item.upstream_params is defined and item.upstream_params is iterable %} {% if item.upstream_params is defined and item.upstream_params is iterable %}
{% for param in item.upstream_params %} {% for param in item.upstream_params %}

View File

@@ -2,7 +2,7 @@
{% block template_upstream_location %} {% block template_upstream_location %}
location = /index.php { location = /index.php {
fastcgi_pass php; fastcgi_pass {{ php_upstream }};
fastcgi_index index.php; fastcgi_index index.php;
{% if item.upstream_params is defined and item.upstream_params is iterable %} {% if item.upstream_params is defined and item.upstream_params is iterable %}
{% for param in item.upstream_params %} {% for param in item.upstream_params %}

View File

@@ -1,16 +1,14 @@
{% extends "_base.j2" %} {% extends "_base.j2" %}
{% block root %}
{% if item.root is defined %}
root {{ item.root }};
{% endif %}
{% endblock %}
{% block template_try_files %} {% block template_try_files %}
proxy_set_header Host $host; include {{ nginx_etc_dir }}/proxy_params;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://{{ item.upstream_name }}; proxy_pass http://{{ item.upstream_name }};
proxy_read_timeout 90;
{#proxy_redirect http://{{ upstream.name }} https://jenkins.domain.tld;#}
{% if item.proxy_params is defined and item.proxy_params is iterable %} {% if item.proxy_params is defined and item.proxy_params is iterable %}
{% for param in item.proxy_params %} {% for param in item.proxy_params %}
{{ param }} {{ param }}

View File

@@ -0,0 +1,14 @@
{% extends "_base.j2" %}
{% block root %}
{% endblock %}
{% block template_index %}
{% endblock %}
{% block template_try_files %}
return {{ item.redirect_to_code | default('302') }} {{ item.redirect_to }}$request_uri;
{% endblock %}
{% block template_local_content %}
{% endblock %}

View File

@@ -3,3 +3,9 @@
{% block template_try_files %} {% block template_try_files %}
try_files $uri $uri/ /index.php?$args; try_files $uri $uri/ /index.php?$args;
{% endblock %} {% endblock %}
{% block template_custom_location %}
location ~* /(?:uploads|files)/.*\.php$ {
deny all;
}
{% endblock %}

View File

@@ -2,8 +2,9 @@
# {{ ansible_managed }} # {{ ansible_managed }}
# #
upstream php { {% if nginx_php56 %}
{% for item in nginx_php_sockets %} upstream {{ nginx_upstream_php56 }} {
{% for item in nginx_php56_sockets %}
{% if item.unix_socket is defined %} {% if item.unix_socket is defined %}
server unix:{{ item.unix_socket }} weight={{ item.weight | default('1') }}; server unix:{{ item.unix_socket }} weight={{ item.weight | default('1') }};
{% else %} {% else %}
@@ -12,4 +13,18 @@ upstream php {
{% endfor %} {% endfor %}
} }
{% endif %}
{% if nginx_php70 %}
upstream {{ nginx_upstream_php70 }} {
{% for item in nginx_php70_sockets %}
{% if item.unix_socket is defined %}
server unix:{{ item.unix_socket }} weight={{ item.weight | default('1') }};
{% else %}
server {{ item.host }}:{{ item.port }} weight={{ item.weight | default('1') }} max_fails={{ item.max_fails | default('5') }} fail_timeout={{ item.fail_timeout | default('10s') }};
{% endif %}
{% endfor %}
}
{% endif %}
# vim:filetype=nginx # vim:filetype=nginx

View File

@@ -1,4 +1,4 @@
FROM williamyeh/ansible:debian8-onbuild FROM williamyeh/ansible:debian8-onbuild
RUN apt-get update RUN apt-get update
CMD ["sh", "tests/test.sh"] CMD ["sh", "tests/travis.sh"]

View File

@@ -1,4 +0,0 @@
FROM williamyeh/ansible:debian7-onbuild
RUN apt-get update
CMD ["sh", "tests/test.sh"]

19
tests/file/test.crt Normal file
View File

@@ -0,0 +1,19 @@
-----BEGIN CERTIFICATE-----
MIIDHTCCAgWgAwIBAgIJAJzUwbFlhyxIMA0GCSqGSIb3DQEBCwUAMCUxIzAhBgNV
BAMMGnRlc3Qtc3NsLXByZWRlcGxveWVkLmxvY2FsMB4XDTE2MDExMjE2MDUxNVoX
DTI2MDEwOTE2MDUxNVowJTEjMCEGA1UEAwwadGVzdC1zc2wtcHJlZGVwbG95ZWQu
bG9jYWwwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDm4q94vffiU89G
GO7rjDfr3C32tH9sM5sXqJT+7N5BLYLF0iSRIvy33MtwFu//TV3f+8nLlQuHYVVk
L6NEvaL8lh+nRexCQ/y+aXMh7lMhuwPXGgPR1LXsTqyDXbmV9c7k/Kwx5qHAcOb9
d9YzmcOSO4M9v3WMl/4Zw2J7zNYruypxNBgFEwFx3NJ3AztACMYoVOIR5mS8ARX6
xea4ddii1F41Vch+eiCGP9VZwDhEujhjy9PXvdBtYNwggM6d82Df9wwaFyIW5DU4
PhpgAngvE2keY0GLy/LaXa6LAW+TCfPMRT2RtDuvqWr+useWF+O3n81TZqM/G7LV
9iPxkkRNAgMBAAGjUDBOMB0GA1UdDgQWBBSzXW5UY02/S0xrrobZCVOhas6VeDAf
BgNVHSMEGDAWgBSzXW5UY02/S0xrrobZCVOhas6VeDAMBgNVHRMEBTADAQH/MA0G
CSqGSIb3DQEBCwUAA4IBAQC0+Tr0w9aG4f3LG3+WRGKfMopKICNEkA7JrPrvVUq8
7UgtdrpOUZAL5AKxVVo1rHDdoL/VpjdqHdhyPzaSUl8hppCFsWmdQh4wLKGoyvcN
AqSGpXTeLSoFJ357F2OIQpXm2lfT2fVGebwyCNFkwpp7klFnmOusSl2/v5Y5cz+A
WvWrDg3jsNglx3mNLVcjbOSnen2PsZSmcVo27D0el6oDju8jjstyJ+Dvu0WP+CDL
s/VolFdbei7d4r2dj86OZ/BCZurltyc0wI3NMOdUuA7q4f1MPTRu7qr/ua5ItK92
Avc+Gjn/Y/aIhzKpPicJQDK6FzxjfhCc8xtk0EjB4IpP
-----END CERTIFICATE-----

28
tests/file/test.key Normal file
View File

@@ -0,0 +1,28 @@
-----BEGIN PRIVATE KEY-----
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDm4q94vffiU89G
GO7rjDfr3C32tH9sM5sXqJT+7N5BLYLF0iSRIvy33MtwFu//TV3f+8nLlQuHYVVk
L6NEvaL8lh+nRexCQ/y+aXMh7lMhuwPXGgPR1LXsTqyDXbmV9c7k/Kwx5qHAcOb9
d9YzmcOSO4M9v3WMl/4Zw2J7zNYruypxNBgFEwFx3NJ3AztACMYoVOIR5mS8ARX6
xea4ddii1F41Vch+eiCGP9VZwDhEujhjy9PXvdBtYNwggM6d82Df9wwaFyIW5DU4
PhpgAngvE2keY0GLy/LaXa6LAW+TCfPMRT2RtDuvqWr+useWF+O3n81TZqM/G7LV
9iPxkkRNAgMBAAECggEAEEeZkczrRpUcP1gQuKEZbFMJFqUhevKkk+V6JAN1pGje
GK65j1ZFNX2nBo9Hetvsq5doYidvOat+RuMpAvbQIDlBoBzJDN8YWiC7UoAocm9q
VOdrr4btEO13MogQRuefH/xE8/vMGfKcBvFFNDw6UvxJQ7hVRIWPECf7sLj/vPOC
OpMKghxcabQqidMPKyyHVPhQjuIvqW/SqBFpD+Ul0Ja1QGdx+p+/EwVmXnei6Kr8
/ypULreHqIlBLD6McfFehxDV0m5U7qXb5xK3zdUurIhZixKLjbdRrorNInfEvlOh
vDy+hsF5GSzvn9dRrMAy/QcRPpXU47VNYZ5BfdCBTQKBgQD8VCbdpG5siXSlIjZd
xypgK1ttp8udTPWC1trnAc+Ku9O+cGmvABxYJA1iR/GDpSfMxglB7OhSecywKrr+
S7Yjs9e/dyBmvF7U15JJaGp+db2Ct64z7MvqkwSJ5a0qrrZJRFetDdqdH9FPvURs
B147jbKsPiGcljjXbZlOBHJH9wKBgQDqPqoA3VqYOmvR7Ei8/skY2EOpFpOhSNko
ARFwUsDNHRk677URH97TCHq5UrwubfCeIcIptXHrMfaTsfq8vPLPykReIMRaknxf
DULJPHSoeBLrCAZmaWF1JVyYhrLhHNAzQ3u7a/kYIJm87FEZy3Ml6FSZmIGbRBqx
zqZYKoHs2wKBgQD469tbk7cLg556uYGAidYYAS20w29uwlkAtgxFD9g6OIjuud7I
MQfFO+uoJOjwwaC9ti+zxY56roVq1PybmP0Zw3T3AQIJ15KFzhQWLte/4U8PATzt
JJEV2+sCTn3COZDCPpVvttcPYjAOxdwV5j7j6Sl2GeT2oIt6mjg+asyCiQKBgQDk
LPxu8TBRfv8OMqs8Jrf/EpL9/7b48bxOwpOZJZMXelPcXCm1r6TfTrA1HAmg9Ijh
kKLQ/CUm5Ll7b3B+L1Qa4r2sLyD11SF/eaxn2BMPFD/hYCTT160ObsF+9h8DN4z7
kq3RiMDRJth69nuds9fLwj++ipcdhr62G0VgNq/u5wKBgCz/I5J3tPNjrU9YampR
0gNnUkUfJWbiVMsG9uwL9l0L/ZzQHvELJ523QXQ0v/e/szHCyoX319u8HEQlC0Jw
Twlj81HDZzruDUB/mcH6Ee3zHKOmmF6ma+CgoYJJElKW89MUttPdmkH2J1QqLz+7
EGREwqjr8/wm22DzKNiyDXJ0
-----END PRIVATE KEY-----

View File

@@ -0,0 +1,11 @@
---
- name: APT | Install web apps
apt: pkg={{ item }} state=present install_recommends=no
with_items:
- backuppc
- nagios3
# - owncloud
- name: SERVICE | Ensure backuppc is started
service: name=backuppc state=started

View File

@@ -0,0 +1,31 @@
---
- name: APT | Install web apps
pkgng: pkg={{ item }} state=present
with_items:
- nagios
- backuppc
- name: COMMAND | Activate backuppc config
command: >
cp /usr/local/etc/backuppc/config.pl.sample /usr/local/etc/backuppc/config.pl
creates=/usr/local/etc/backuppc/config.pl
- name: FILE | Fix backuppc permissions
file: >
path=/usr/local/etc/backuppc/config.pl
owner=backuppc
group=backuppc
- name: FILE | Fix fcgiwrap permission
file: >
path={{ nginx_fcgiwrap_sock }}
mode=0640
owner={{ nginx_user }}
group={{ nginx_user }}
#
# We don't manage BackupPC on FreeBSD... too dirty. :/
#
#- name: SERVICE | Ensure backuppc is started
# service: name=backuppc state=started enabled=yes

View File

@@ -0,0 +1,47 @@
---
- name: APT_REPOSITORY | Install backports
apt_repository: repo='deb http://httpredir.debian.org/debian {{ ansible_distribution_release }}-backports main' state=present
- block:
- name: APT | Install DotDeb key
apt_key: url='http://www.dotdeb.org/dotdeb.gpg' state=present
- name: APT_REPOSITORY | Install dotdeb (PHP 7)
apt_repository: repo='deb http://packages.dotdeb.org {{ ansible_distribution_release }} all' state=present
- name: LINEFILEFILE | Dotdeb priority (prevent install nginx from dotdeb)
copy: >
content="Package: *\nPin: release o=packages.dotdeb.org\nPin-Priority: 100"
dest=/etc/apt/preferences
when: ansible_distribution_release == 'jessie' and dotdeb
- name: APT | Install needed packages
apt: pkg={{ item }} update_cache=yes cache_valid_time=3600 state=present
with_items:
- curl
- fcgiwrap
- nghttp2
- strace
- vim
- name: APT | Install PHP5.6
apt: pkg={{ item }} update_cache=yes cache_valid_time=3600 state=present
with_items:
- php5-fpm
- php5-sqlite
when: nginx_php56
- name: APT | Install PHP7
apt: pkg={{ item }} update_cache=yes cache_valid_time=3600 state=present
with_items:
- php7.0-fpm
- php7.0-sqlite3
when: nginx_php70
- name: SERVICE | Force start services
service: name={{ item.name }} state=started
register: sf
with_items:
- { name: 'php5-fpm', cond: "{{ nginx_php56 }}" }
- { name: 'php7.0-fpm', cond: "{{ nginx_php70 }}" }
- { name: 'fcgiwrap', cond: true }
when: "{{ item.cond }}"

View File

@@ -0,0 +1,25 @@
---
- name: SET_FACT | FreeBSD web user
set_fact:
nginx_pkgng_package: 'nginx-devel'
nginx_user: 'www'
nginx_php70: false
nginx_php56_sockets:
- host: '127.0.0.1'
port: 9000
- name: PKGNG | Install needed packages
pkgng: pkg={{ item }} state=present
with_items:
- php56
- curl
- fcgiwrap
- nghttp2
- name: SERVICE | Force start services
service: name={{ item }} state=started enabled=yes
register: sf
with_items:
- php-fpm
- fcgiwrap

View File

@@ -1 +0,0 @@
localhost

View File

@@ -1,21 +0,0 @@
#!/bin/sh
# Thanks to https://servercheck.in/blog/testing-ansible-roles-travis-ci-github
DIR=$( dirname $0 )
INVENTORY_FILE="$DIR/inventory"
PLAYBOOK="$DIR/test.yml"
set -ev
# Check syntax
ansible-playbook -i $INVENTORY_FILE -c local --syntax-check -vv $PLAYBOOK
# Check role
ansible-playbook -i $INVENTORY_FILE -c local --sudo -vv $PLAYBOOK
# Check indempotence
ansible-playbook -i $INVENTORY_FILE -c local --sudo -vv $PLAYBOOK \
| grep -q 'changed=0.*failed=0' \
&& (echo 'Idempotence test: pass' && exit 0) \
|| (echo 'Idempotence test: fail' && exit 1)

View File

@@ -2,12 +2,25 @@
- hosts: all - hosts: all
pre_tasks: pre_tasks:
- apt: pkg={{ item }} update_cache=yes cache_valid_time=3600 state=present - debug: var=dotdeb
with_items: - debug: var=nginx_php56
- php5-fpm - debug: var=nginx_php70
- curl - debug: var=nginx_backports
- name: INCLUDE | Pre_tasks related to OS version
include: "includes/pre_{{ ansible_distribution }}.yml"
- name: FILE | Create an internal SSL dir
file: path={{ int_ansible_ssl_dir }} state=directory
- name: COPY | Deploy test certificate
copy: src=file/test.crt dest={{ int_ansible_ssl_dir }}/test.crt
- name: COPY | Deploy test key
copy: src=file/test.key dest={{ int_ansible_ssl_dir }}/test.key
vars: vars:
nginx_php: true # Internal vars
int_ansible_ssl_dir: '/etc/ansible-ssl'
# Role vars
nginx_worker_processes: 1 # Ansible+FreeBSD can't detect CPU number
nginx_apt_package: 'nginx-extras'
nginx_dyn_modules: ['http_geoip']
nginx_upstreams: nginx_upstreams:
- name: 'test' - name: 'test'
servers: servers:
@@ -15,14 +28,108 @@
max_conns: 150 max_conns: 150
weight: 10 weight: 10
down: false down: false
- name: 'test-absent'
servers:
- path: '127.0.0.1:80'
max_conns: 150
weight: 10
down: false
state: 'absent'
nginx_htpasswd:
- name: 'hello'
description: 'Please login!'
users:
- name: 'hx'
password: 'asdfg'
state: 'absent'
- name: 'hanx'
password: 'qwerty'
- name: 'nagios'
description: 'Please login to Nagios!'
users:
- name: 'nagiosadmin'
password: 'nagios'
- name: 'deleteme'
description: 'Please login!'
users: []
state: 'absent'
nginx_ssl_pairs:
- name: 'test-ssl-predeployed.local'
dest_key: "{{ int_ansible_ssl_dir }}/test.key"
dest_cert: "{{ int_ansible_ssl_dir }}/test.crt"
- name: 'test-ssl.local'
key: |
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEAvavrJWFp3Al2VwRgKx+4Y2mbRRvoxvyd2pyN0xMJ/tCJscaG
8s60v6WZ9FcCOeMkSI2DXsk4z7pbQdQn0h2GDr/5MOJkPAVWSWEN46tpaLZ3v0zp
88ZIbnEk1G0PsdFuW/pnLsakPlAMrl1VArFsV6YsatLt30UIYYcRO97StkoOehCx
A5w+XqtfHZeQZ0/DS81633gwYUcMuSTUFZ60r7ge1/m77DTSKg3rTVk5sebP8cjS
+aWHvxP/GyvvDsT+3gjRJx2/5O3JkfH0zaOsaU2Avj0PR0c5rhynrNO/l1k+GJJB
cbBrM+yA8Ofzp4oXUrCfaIq3RuL3Pd+khcKsiwIDAQABAoIBAQCPpAMQ7BUfbosQ
m1+5SOx7XR8Z12kSSX3CcY12rJSFRakB2TeZ6rE38lIFmV82N67iw0kaH4nGx3sU
/3aoyXMc+IXfX5RJYEFYkQfTw5ywkH9fgQAsfZ2dBlK+DVo1cEYDoj9CTW1VQ4pX
Ape+0l8agd5hiBxdWgpe0ctbbARnx584viLiA/iPBDNxKi9zEYw+WP7hSj5QWahr
a09tubcC4L6tjvv8CoZTRSKfCW64vWRDvE6vmA+zJN9Arc1WTYzF1KO1Gybwf8h7
stJb191smAgGDFhKo0j58ncyAnrS1k4mapm86QQhlfIA6DKvvC0qm3KdQns5b7HM
PyzW0hwBAoGBAO2mTVTOsziom9vtBwM0nRMMEgynR2X3EKMJz2mjcCf66f1F+aQ5
DvQFM2V8S2s1nGnPh8NKKZ8DxW1NKuR4qx82zeAXpUs9ibHxOnw4YRC485zqc2Wt
fSO1OEDYeKyzWP1nGGtCntYUXzJnWn/wz0mBGKzLKTuLwyFIKx1b7bybAoGBAMxR
N+lT57rX6d4GUqcgNOuWMZ/D8egnE5+hsoiFnHOisRLOgUgBBSy4rwAZx+rdHYT+
RO11L1PLYEzyvnO0f13R+N7aqKwNXDSzZGA+jb4pjkVidIC2smG/JYKJH5Z+kakw
mwMKP0wdRZJsCaMgScHmWJS8d6Ox/XJJoWrTWTbRAoGAWJlEgVaiaIArwz1F/QLz
gHNik0cWDkSi9jWlFxwwpycbbypUXM5M7dq2g6JoN6sACk6trbgLdlYgl5RKZm06
VuPGs0H9hOSHXkix5jfasDJT2G9r4D9ixRo9w6cwriobBjYWW3612tgzeYYgrkwn
655uhZUkZSfA8rqGIGbyZfsCgYAf5WH8G+wmIATTc1s92epJCOZwUY+XNVp75itP
4sPczX4lOHW4PuiG5cH0GxI5mRE9rNAn3c5on2xGNvMCbyAfDmNyruH8Eg3d8E9w
MvO/xw79x/P2EA9i8QszCKMUxGeK6RqZ6+SbxkoRJKqQe77n9UTI228179hoGhSH
77ySsQKBgQC8SSZn6a8PpSIIFXB9WCFMwfGFYbUz0wvpaeZP8GKx3BEzMeJqSUaJ
hrQgpwQXkueeamlCQcvV3AUCoBRWTYRLDrWiUIXuIgikDWBFp6TBvTnVRI7iktly
fNED7jXOSjJqnFmdkZlAI5V8dM++mVYVykJD6jcaVRQvxqFLrhSaRg==
-----END RSA PRIVATE KEY-----
cert: |
-----BEGIN CERTIFICATE-----
MIIDBTCCAe2gAwIBAgIJALKJfbk5vuieMA0GCSqGSIb3DQEBBQUAMBkxFzAVBgNV
BAMMDnRlc3Qtc3NsLmxvY2FsMB4XDTE2MDExMTE2NDI0NFoXDTI2MDEwODE2NDI0
NFowGTEXMBUGA1UEAwwOdGVzdC1zc2wubG9jYWwwggEiMA0GCSqGSIb3DQEBAQUA
A4IBDwAwggEKAoIBAQC9q+slYWncCXZXBGArH7hjaZtFG+jG/J3anI3TEwn+0Imx
xobyzrS/pZn0VwI54yRIjYNeyTjPultB1CfSHYYOv/kw4mQ8BVZJYQ3jq2lotne/
TOnzxkhucSTUbQ+x0W5b+mcuxqQ+UAyuXVUCsWxXpixq0u3fRQhhhxE73tK2Sg56
ELEDnD5eq18dl5BnT8NLzXrfeDBhRwy5JNQVnrSvuB7X+bvsNNIqDetNWTmx5s/x
yNL5pYe/E/8bK+8OxP7eCNEnHb/k7cmR8fTNo6xpTYC+PQ9HRzmuHKes07+XWT4Y
kkFxsGsz7IDw5/OnihdSsJ9oirdG4vc936SFwqyLAgMBAAGjUDBOMB0GA1UdDgQW
BBRaSF1L+ivPhmIVGQjtviBqZWDS9DAfBgNVHSMEGDAWgBRaSF1L+ivPhmIVGQjt
viBqZWDS9DAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4IBAQCjrgB9+Zuq
Rx7T2mRUl4jf75dLabuBQD0ePALTtvNyBSghhzSr90mE7GlFOYAv0JsmEa3R1LVF
wLPIdrIhNHpt7hN0PkhUlfgmxBnRSCfhpiq4xxsDVFM7ehtDz4+dv1LUDMXo07+E
f24g9aqmypiFzHisUQrYIhtQmHxRpKyGp6kDAW9qNxg6k/Um00aHdYfuD9ER4ksR
f8Hto7f+vssKxCRY2OZXqq13PxEwC5+hgAUkTdrycA/moXFuHJi3lCnCND7sSzvG
tXBggOusyFZFC4bs2m+V+Z+RN+tK2c/c0nq5HR8MV5HwIm4Z8GoT2/0BfJ00cgWL
lVz0gDBfdH8f
-----END CERTIFICATE-----
nginx_custom_http:
- 'add_header X-ansible 1;'
- 'geoip_country /usr/share/GeoIP/GeoIP.dat;'
- 'map $geoip_country_code $allowed_country {'
- ' default yes;'
- ' MA no;'
- ' DZ no;'
- ' TN no;'
- '}'
nginx_default_vhost: 'first-test'
nginx_default_vhost_ssl: 'test-ssl-predeployed.local'
nginx_vhosts: nginx_vhosts:
- name: - name:
- 'test.local' - 'test.local'
- 'test-alias.local' - 'test-alias.local'
- 'test2-alias.local' - 'test2-alias.local'
template: '_base' template: '_base'
filename : 'first-test'
override_try_files: '$uri $uri index.htm index.html' override_try_files: '$uri $uri index.htm index.html'
headers:
'X-Frame-Options': 'deny always'
'X-ansible-default': '1'
manage_local_content: false manage_local_content: false
use_error_log: true
more: more:
- 'autoindex off;' - 'autoindex off;'
location: location:
@@ -30,17 +137,47 @@
- 'return 403;' - 'return 403;'
'/gunther': '/gunther':
- 'return 404;' - 'return 404;'
'/status':
- 'stub_status on;'
- 'access_log off;'
- 'allow 127.0.0.1;'
- 'deny all;'
- name: 'test-htpasswd.local'
template: '_base'
location:
'/hello':
- htpasswd: 'hello'
'/public':
- htpasswd: false
use_error_log: true
- name: 'test-htpasswd-all.local'
template: '_base'
htpasswd: 'hello'
- name: 'test-location.local' - name: 'test-location.local'
template: '_base' template: '_base'
location: location:
'/': '/':
- 'alias /var/tmp;' - 'alias /var/tmp;'
'/a':
- 'alias /var/tmp;'
'/b':
- 'alias /var/tmp;'
'/c':
- 'alias /var/tmp;'
location_order:
- '/'
- '/a'
- '/b'
- '/c'
- name: 'test-php.local' - name: 'test-php.local'
php_version: "{{ '7.0' if nginx_php70 else '5.6' }}"
upstream_params: upstream_params:
- 'fastcgi_param FOO bar;' - 'fastcgi_param FOO bar;'
redirect_from: redirect_from:
- 'www.test-php.local' - 'www.test-php.local'
template: '_php' template: '_php'
use_error_log: true
use_access_log: true
- name: 'test-php-index.local' - name: 'test-php-index.local'
template: '_php_index' template: '_php_index'
- name: 'test-proxy.local' - name: 'test-proxy.local'
@@ -48,22 +185,76 @@
- 8080 - 8080
template: '_proxy' template: '_proxy'
upstream_name: 'test' upstream_name: 'test'
headers:
'X-proxyfied': '1'
- name: 'deleted.local' - name: 'deleted.local'
state: 'absent'
- name: 'redirect-to.local'
redirect_to: 'http://test.local'
- name: 'backuppc.local'
template: '_backuppc'
htpasswd: 'hello'
- name: 'nagios3.local'
template: '_nagios3'
htpasswd: 'nagios'
- name: 'test-ssl.local'
proto: ['http', 'https']
template: '_base' template: '_base'
delete: true - name: 'test-ssl-predeployed.local'
proto: ['http', 'https']
template: '_base'
ssl_name: 'test-ssl-predeployed.local'
headers:
'X-ansible-default': '1'
ssl_template: false
- name: 'test-ssl-redirect.local'
proto: ['https']
template: '_base'
ssl_name: 'test-ssl.local'
redirect_https: true
- name: 'test-ssl-proxy-protocol.local'
proto: ['http', 'https']
listen: [80, 20080]
listen_ssl: [443, 20443]
http_proxy_protocol_port: [20080]
https_proxy_protocol_port: [20443]
template: '_base'
ssl_name: 'test-ssl.local'
nginx_dh_length: 2048
roles: roles:
- ../../ - ../../
post_tasks: post_tasks:
# --------------------------------
# Apps
# --------------------------------
- name: INCLUDE | Post_tasks related to OS version
include: "includes/post_{{ ansible_distribution }}.yml"
# --------------------------------
# Deploy index files
# --------------------------------
- name: -- Add PHP file -- - name: -- Add PHP file --
copy: dest="{{ nginx_root }}/{{ item }}/public/index.php" content="<?php phpinfo();" copy: dest="{{ nginx_root }}/{{ item }}/public/index.php" content="<?php phpinfo();"
with_items: ['test-php.local', 'test-php-index.local'] with_items: ['test-php.local', 'test-php-index.local']
- name: -- Add HTML file -- - name: -- Add HTML file --
copy: dest="{{ item }}/index.html" content="Index HTML test OK\n" copy: dest="{{ item }}/index.html" content="Index HTML test OK\n"
with_items: ['{{ nginx_root }}/test.local/public', '/var/tmp'] with_items: ['{{ nginx_root }}/first-test/public', '/var/tmp', '{{ nginx_root }}/test-htpasswd-all.local/public', '{{ nginx_root }}/test-ssl.local/public', '{{ nginx_root }}/test-ssl-predeployed.local/public', '{{ nginx_root }}/test-ssl-proxy-protocol.local/public']
- name: -- Create directory --
file: path={{ nginx_root }}/test-htpasswd.local/public/hello state=directory
- name: -- Add HTML file hello --
copy: dest="{{ nginx_root }}/test-htpasswd.local/public/hello/index.html" content="hello\n"
# --------------------------------
# Test custom facts
# --------------------------------
- name: -- CHECK FACTS --
assert:
that: "'{{ ansible_local.nginx.fact_nginx_vhosts[0].name[0] }}' == 'test.local'"
# --------------------------------
# Simple vhosts tests
# --------------------------------
- name: -- VERIFY VHOSTS -- - name: -- VERIFY VHOSTS --
command: "curl -H 'Host: {{ item.name if item.name is string else item.name[0] }}' http://127.0.0.1{% if item.listen is defined %}:{{ item.listen[0] }}{% endif %}/" command: "curl -H 'Host: {{ item.name if item.name is string else item.name[0] }}' http://127.0.0.1{% if item.listen is defined %}:{{ item.listen[0] }}{% endif %}/"
with_items: nginx_vhosts with_items: "{{ nginx_vhosts }}"
when: item.delete is undefined or not item.delete when: item.state is undefined or item.state != "absent"
changed_when: false changed_when: false
- name: -- VERIFY FORBIDDEN -- - name: -- VERIFY FORBIDDEN --
command: "curl -H 'Host: test-php-index.local' http://127.0.0.1/phpinfo.php" command: "curl -H 'Host: test-php-index.local' http://127.0.0.1/phpinfo.php"
@@ -72,8 +263,167 @@
changed_when: false changed_when: false
- name: -- VERIFY REDIRECT VHOSTS -- - name: -- VERIFY REDIRECT VHOSTS --
command: "curl -H 'Host: {{ item.redirect_from[0] }}' http://127.0.0.1/" command: "curl -H 'Host: {{ item.redirect_from[0] }}' http://127.0.0.1/"
with_items: nginx_vhosts with_items: "{{ nginx_vhosts }}"
when: item.redirect_from is defined and (item.delete is undefined or not item.delete) when: item.redirect_from is defined and (item.state is undefined or item.state != "absent")
changed_when: false changed_when: false
register: r register: r
failed_when: r.stdout.find('301 Moved Permanently') == -1 failed_when: r.stdout.find('301 Moved Permanently') == -1
# --------------------------------
# PHP
# --------------------------------
- name: -- VERIFY PHP5 VHOSTS (implicit default) --
command: "curl -H 'Host: {{ item }}' http://127.0.0.1/"
register: p
changed_when: false
failed_when: p.stdout.find('PHP Version 5') == -1
with_items: ['test-php-index.local']
when: nginx_php56
- name: -- VERIFY PHP7 VHOSTS --
command: "curl -H 'Host: {{ item }}' http://127.0.0.1/"
register: p
changed_when: false
failed_when: p.stdout.find('PHP Version 7') == -1
with_items: ['test-php.local']
when: nginx_php70
# --------------------------------
# Basic Auth
# --------------------------------
- name: -- VERIFY AUTH BASIC NONE --
command: "curl -H 'Host: test-htpasswd.local' http://127.0.0.1/hello/"
changed_when: false
register: authnone
failed_when: authnone.stdout.find('401 Authorization Required') == -1
- name: -- VERIFY AUTH BASIC FAIL --
command: "curl -u fail:fail -H 'Host: test-htpasswd.local' http://127.0.0.1/hello/"
changed_when: false
register: authfail
failed_when: authfail.stdout.find('401 Authorization Required') == -1
- name: -- VERIFY AUTH BASIC OK --
command: "curl -u hanx:qwerty -H 'Host: test-htpasswd.local' http://127.0.0.1/hello/"
changed_when: false
register: authok
failed_when: authok.stdout.find('hello') == -1
- name: -- VERIFY AUTH BASIC FAIL GLOBAL --
command: "curl -u fail:fail -H 'Host: test-htpasswd-all.local' http://127.0.0.1/"
changed_when: false
register: authgfail
failed_when: authgfail.stdout.find('401 Authorization Required') == -1
- name: -- VERIFY AUTH BASIC OK --
command: "curl -u hanx:qwerty -H 'Host: test-htpasswd-all.local' http://127.0.0.1/"
changed_when: false
register: authgok
failed_when: authgok.stdout.find('401 Authorization Required') != -1
# --------------------------------
# BackupPC
# --------------------------------
- name: -- VERIFY BACKUPPC --
command: "curl -u hanx:qwerty -H 'Host: backuppc.local' http://127.0.0.1/"
changed_when: false
register: authbpc
failed_when: authbpc.stdout.find('BackupPC Server Status') == -1
when: ansible_distribution != 'FreeBSD'
# --------------------------------
# Nagios
# --------------------------------
- name: -- VERIFY NAGIOS3 PHP --
command: "curl -u nagiosadmin:nagios -H 'Host: nagios3.local' http://127.0.0.1/side.php"
changed_when: false
register: nagios_php
failed_when: nagios_php.stdout.find('Nagios Core') == -1
- name: -- VERIFY NAGIOS3 CGI --
command: "curl -u nagiosadmin:nagios -H 'Host: nagios3.local' http://127.0.0.1/cgi-bin{% if ansible_distribution == 'Debian' %}/nagios3{% endif %}/summary.cgi"
changed_when: false
register: nagios_cgi
failed_when: nagios_cgi.stdout.find('Nagios Event Summary') == -1
# --------------------------------
# Owncloud
# --------------------------------
# - block:
# - name: -- VERIFY OWNCLOUD --
# command: "curl -H 'Host: owncloud.local' http://127.0.0.1/"
# changed_when: false
# register: ownsimple
# failed_when: ownsimple.stdout.find('ownCloud') == -1
# - name: -- VERIFY OWNCLOUD JS (FROM PHP)--
# command: "curl -H 'Host: owncloud.local' http://127.0.0.1/index.php/core/js/oc.js"
# changed_when: false
# register: ownjsphp
# failed_when: ownjsphp.stdout.find('var oc_debug=false') == -1
# - name: -- VERIFY OWNCLOUD JS --
# command: "curl -H 'Host: owncloud.local' http://127.0.0.1/core/js/js.js"
# changed_when: false
# register: ownjs
# failed_when: ownjs.stdout.find('var oc_debug') == -1
# when: ansible_distribution != 'FreeBSD'
# --------------------------------
# SSL
# --------------------------------
- name: -- VERIFY SSL --
command: "curl --insecure -H 'Host: {{ item }}' https://127.0.0.1/"
changed_when: false
register: sslok
failed_when: sslok.stdout.find('Index HTML test OK') == -1
with_items:
- 'test-ssl-predeployed.local'
- 'test-ssl.local'
- name: -- VERIFY SSL REDIRECT --
command: "curl -v --insecure -H 'Host: {{ item }}' http://127.0.0.1/"
changed_when: false
register: sslredirok
failed_when: >
sslredirok.stderr.find('< Location') == -1 and
sslredirok.stderr.find('https://{{ item }}/') == -1
with_items:
- 'test-ssl-redirect.local'
# --------------------------------
# Default vhosts
# --------------------------------
- name: -- VERIFY DEFAULT VHOST --
command: "curl -v http://127.0.0.1/"
changed_when: false
register: vdefault
failed_when: >
vdefault.stdout.find('Index HTML test OK') == -1 or
vdefault.stderr.find('X-ansible-default') == -1
- name: -- VERIFY DEFAULT SSL VHOST --
command: "curl --insecure -v https://127.0.0.1/"
changed_when: false
register: defaultssl
failed_when: >
defaultssl.stdout.find('Index HTML test OK') == -1 or
defaultssl.stderr.find('X-ansible-default') == -1
- name: -- VERIFY NOT DEFAULT VHOST --
command: "curl -v -H 'Host: test-php.local' http://127.0.0.1/"
changed_when: false
register: vphp
failed_when: vphp.stderr.find('X-ansible-default') != -1
- name: -- VERIFY NOT DEFAULT SSL VHOST --
command: "curl --insecure -v -H 'Host: test-ssl.local' https://127.0.0.1/"
changed_when: false
register: notdefaultssl
failed_when: notdefaultssl.stderr.find('X-ansible-default') != -1
- name: -- VERIFY DEFAULT VHOST + STUB_STATUS --
command: "curl -v http://127.0.0.1/status"
changed_when: false
register: vdefault_status
failed_when: >
vdefault_status.stderr.find('X-ansible-default') == -1 or
vdefault_status.stdout.find('Active connections') == -1
# --------------------------------
# Check HTTP2
# --------------------------------
- name: SHELL | Check HTTP2
shell: nghttp -nv https://localhost 2> /dev/null | grep -q h2
args:
executable: /bin/sh
changed_when: false
when: nginx_auto_config_httpv2 and 'http_v2' in nginx_modules

25
tests/travis.sh Normal file
View File

@@ -0,0 +1,25 @@
#!/bin/sh
# Thanks to https://servercheck.in/blog/testing-ansible-roles-travis-ci-github
DIR=$( dirname $0 )
PLAYBOOK="$DIR/test.yml"
set -ev
ANSIBLE_VARS="{ nginx_php56: $NGINX_PHP56, nginx_php70: $NGINX_PHP70, nginx_backports: $NGINX_BACKPORTS, dotdeb: $DOTDEB }"
echo $ANSIBLE_VARS
# Check syntax
ansible-playbook -i localhost, -c local --syntax-check -vv $PLAYBOOK
# Check role
ansible-playbook -i localhost, -c local -e "$ANSIBLE_VARS" --sudo -vv $PLAYBOOK
# Check indempotence
ansible-playbook -i localhost, -c local -e "$ANSIBLE_VARS" --sudo -vv $PLAYBOOK \
| grep -q 'changed=0.*failed=0' \
&& (echo 'Idempotence test: pass' && exit 0) \
|| (echo 'Idempotence test: fail' && exit 1)

8
vars/Debian.yml Normal file
View File

@@ -0,0 +1,8 @@
nginx_events_use: 'epoll'
nginx_pid: '/run/nginx.pid'
nginx_etc_dir: '/etc/nginx'
# Specific vhosts
nginx_nagios_root: '/usr/share/nagios3/htdocs'
nginx_nagios_stylesheets: '/etc/nagios3/stylesheets'
nginx_fcgiwrap_sock: '/var/run/fcgiwrap.socket'

7
vars/FreeBSD.yml Normal file
View File

@@ -0,0 +1,7 @@
nginx_events_use: 'kqueue'
nginx_pid: '/var/run/nginx.pid'
nginx_etc_dir: '/usr/local/etc/nginx'
# Specific vhosts
nginx_nagios_root: '/usr/local/www/nagios'
nginx_fcgiwrap_sock: '/var/run/fcgiwrap/fcgiwrap.sock'

View File

@@ -1,5 +1,3 @@
nginx_dh_path: /etc/nginx/ssl/dhparams.pem
nginx_upstream_server_params: nginx_upstream_server_params:
- key: 'weight' - key: 'weight'
default: 1 default: 1
@@ -23,3 +21,28 @@ nginx_upstream_server_params:
# - key: 'resolve' # - key: 'resolve'
# is_bool: true # is_bool: true
# min_version: '1.5.12' # min_version: '1.5.12'
nginx_dirs:
- dir: "{{ nginx_htpasswd_dir }}"
mode: "0750"
owner: "{{ nginx_user }}"
- dir: "{{ nginx_ssl_dir }}"
mode: "0750"
owner: "root"
- dir: "{{ nginx_helper_dir }}"
mode: "0755"
owner: "root"
nginx_templates_no_dir:
- '_backuppc'
- '_nagios3'
- '_owncloud'
- '_proxy'
nginx_servers_default_headers:
'X-Frame-Options': 'DENY always'
'X-Content-Type-Options': 'nosniff always'
'X-XSS-Protection': '1; mode=block'
nginx_upstream_php56: 'php56'
nginx_upstream_php70: 'php70'