From a3a6f279b94ec93536184a901a7ba87f7f2a548e Mon Sep 17 00:00:00 2001 From: Jeff Geerling Date: Fri, 31 Mar 2017 11:24:44 -0500 Subject: [PATCH 01/26] Add a LICENSE file for MIT license. [ci skip] --- LICENSE | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..4275cf3 --- /dev/null +++ b/LICENSE @@ -0,0 +1,20 @@ +The MIT License (MIT) + +Copyright (c) 2017 Jeff Geerling + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. From 8616f4cf2f5d1ac5a2568a18d0d100f28164e4d0 Mon Sep 17 00:00:00 2001 From: Jeff Geerling Date: Sat, 1 Apr 2017 23:34:07 -0500 Subject: [PATCH 02/26] Switch to more efficient and compact test setup. --- .gitignore | 2 ++ .travis.yml | 37 +++++-------------------------------- tests/README.md | 11 +++++++++++ 3 files changed, 18 insertions(+), 32 deletions(-) create mode 100644 .gitignore create mode 100644 tests/README.md diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c9b2377 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.retry +tests/test.sh diff --git a/.travis.yml b/.travis.yml index c1f9860..85eea53 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,44 +3,17 @@ services: docker env: - distro: centos7 - init: /usr/lib/systemd/systemd - run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro" - distro: ubuntu1604 - init: /lib/systemd/systemd - run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro" - distro: ubuntu1404 - init: /sbin/init - run_opts: "" - distro: ubuntu1204 - init: /sbin/init - run_opts: "" - -before_install: - # Pull container. - - 'docker pull geerlingguy/docker-${distro}-ansible:latest' script: - - container_id=$(mktemp) - # Run container in detached state. - - 'docker run --detach --volume="${PWD}":/etc/ansible/roles/role_under_test:ro ${run_opts} geerlingguy/docker-${distro}-ansible:latest "${init}" > "${container_id}"' - - # Ansible syntax check. - - 'docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml --syntax-check' - - # Test role. - - 'docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml' - - # Test role idempotence. - - idempotence=$(mktemp) - - docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml | tee -a ${idempotence} - - > - tail ${idempotence} - | grep -q 'changed=0.*failed=0' - && (echo 'Idempotence test: pass' && exit 0) - || (echo 'Idempotence test: fail' && exit 1) + # Download test shim. + - wget -O ${PWD}/tests/test.sh https://gist.githubusercontent.com/geerlingguy/73ef1e5ee45d8694570f334be385e181/raw/ + - chmod +x ${PWD}/tests/test.sh - # Check if nginx is running. - # TODO + # Run tests. + - ${PWD}/tests/test.sh notifications: webhooks: https://galaxy.ansible.com/api/v1/notifications/ diff --git a/tests/README.md b/tests/README.md new file mode 100644 index 0000000..77b2772 --- /dev/null +++ b/tests/README.md @@ -0,0 +1,11 @@ +# Ansible Role tests + +To run the test playbook(s) in this directory: + + 1. Install and start Docker. + 1. Download the test shim (see .travis.yml file for the URL) into `tests/test.sh`: + - `wget -O tests/test.sh wget -O ${PWD}/tests/test.sh https://gist.githubusercontent.com/geerlingguy/73ef1e5ee45d8694570f334be385e181/raw/` + 1. Make the test shim executable: `chmod +x tests/test.sh`. + 1. Run (from the role root directory) `distro=[distro] playbook=[playbook] ./tests/test.sh` + +If you don't want the container to be automatically deleted after the test playbook is run, add the following environment variables: `cleanup=false container_id=$(date +%s)` From 10548f190961d405e6a63656e9a79162b24cd088 Mon Sep 17 00:00:00 2001 From: Jeff Geerling Date: Sun, 2 Apr 2017 10:41:46 -0500 Subject: [PATCH 03/26] Update test script README. [ci skip] --- tests/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/README.md b/tests/README.md index 77b2772..6fb2117 100644 --- a/tests/README.md +++ b/tests/README.md @@ -4,7 +4,7 @@ To run the test playbook(s) in this directory: 1. Install and start Docker. 1. Download the test shim (see .travis.yml file for the URL) into `tests/test.sh`: - - `wget -O tests/test.sh wget -O ${PWD}/tests/test.sh https://gist.githubusercontent.com/geerlingguy/73ef1e5ee45d8694570f334be385e181/raw/` + - `wget -O tests/test.sh https://gist.githubusercontent.com/geerlingguy/73ef1e5ee45d8694570f334be385e181/raw/` 1. Make the test shim executable: `chmod +x tests/test.sh`. 1. Run (from the role root directory) `distro=[distro] playbook=[playbook] ./tests/test.sh` From f8a04dd544630f3574f13fb117dbe223027406fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Sch=C3=B6ldstr=C3=B6m?= Date: Sat, 25 Mar 2017 13:15:04 -0500 Subject: [PATCH 04/26] Write vhost configurations to separate config files --- tasks/vhosts.yml | 19 ++++++++++++------- templates/vhost.j2 | 31 +++++++++++++++++++++++++++++++ templates/vhosts.j2 | 33 --------------------------------- 3 files changed, 43 insertions(+), 40 deletions(-) create mode 100644 templates/vhost.j2 delete mode 100644 templates/vhosts.j2 diff --git a/tasks/vhosts.yml b/tasks/vhosts.yml index cf27c14..9c4ef43 100644 --- a/tasks/vhosts.yml +++ b/tasks/vhosts.yml @@ -12,17 +12,22 @@ state: directory notify: reload nginx -- name: Add managed vhost config file (if any vhosts are configured). +- name: Add managed vhost config files. template: - src: vhosts.j2 - dest: "{{ nginx_vhost_path }}/{{ nginx_vhosts_filename }}" + src: vhost.j2 + dest: "{{ nginx_vhost_path }}/{{ item.server_name.split(' ')[0] }}.conf" + force: yes + owner: root + group: root mode: 0644 - when: nginx_vhosts|length > 0 + when: "{{ item.state|default('present') != 'absent' }}" + with_items: "{{ nginx_vhosts }}" notify: reload nginx -- name: Remove managed vhost config file (if no vhosts are configured). +- name: Remove managed vhost config files. file: - path: "{{ nginx_vhost_path }}/{{ nginx_vhosts_filename }}" + path: "{{ nginx_vhost_path }}/{{ item.server_name.split(' ')[0] }}.conf" state: absent - when: nginx_vhosts|length == 0 + when: "{{ item.state|default('present') == 'absent' }}" + with_items: "{{ nginx_vhosts }}" notify: reload nginx diff --git a/templates/vhost.j2 b/templates/vhost.j2 new file mode 100644 index 0000000..80aa6ad --- /dev/null +++ b/templates/vhost.j2 @@ -0,0 +1,31 @@ +server { + listen {{ item.listen | default('80 default_server') }}; + +{% if item.server_name is defined %} + server_name {{ item.server_name }}; +{% endif %} + +{% if item.root is defined %} + root {{ item.root }}; +{% endif %} + + index {{ item.index | default('index.html index.htm') }}; + +{% if item.error_page is defined %} + error_page {{ item.error_page }}; +{% endif %} +{% if item.access_log is defined %} + access_log {{ item.access_log }}; +{% endif %} +{% if item.error_log is defined %} + error_log {{ item.error_log }} error; +{% endif %} + +{% if item.return is defined %} + return {{ item.return }}; +{% endif %} + +{% if item.extra_parameters is defined %} + {{ item.extra_parameters|indent(4) }} +{% endif %} +} diff --git a/templates/vhosts.j2 b/templates/vhosts.j2 deleted file mode 100644 index e4e8c05..0000000 --- a/templates/vhosts.j2 +++ /dev/null @@ -1,33 +0,0 @@ -{% for vhost in nginx_vhosts %} -server { - listen {{ vhost.listen | default('80 default_server') }}; - -{% if vhost.server_name is defined %} - server_name {{ vhost.server_name }}; -{% endif %} - -{% if vhost.root is defined %} - root {{ vhost.root }}; -{% endif %} - - index {{ vhost.index | default('index.html index.htm') }}; - -{% if vhost.error_page is defined %} - error_page {{ vhost.error_page }}; -{% endif %} -{% if vhost.access_log is defined %} - access_log {{ vhost.access_log }}; -{% endif %} -{% if vhost.error_log is defined %} - error_log {{ vhost.error_log }} error; -{% endif %} - -{% if vhost.return is defined %} - return {{ vhost.return }}; -{% endif %} - -{% if vhost.extra_parameters is defined %} - {{ vhost.extra_parameters|indent(4) }} -{% endif %} -} -{% endfor %} From 3f0442fe637dfa4be903c433a7e7859daf105308 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Sch=C3=B6ldstr=C3=B6m?= Date: Sat, 25 Mar 2017 15:24:34 -0500 Subject: [PATCH 05/26] Set default listen value to 80 rather than 80 default_server --- templates/vhost.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/vhost.j2 b/templates/vhost.j2 index 80aa6ad..35e3de1 100644 --- a/templates/vhost.j2 +++ b/templates/vhost.j2 @@ -1,5 +1,5 @@ server { - listen {{ item.listen | default('80 default_server') }}; + listen {{ item.listen | default('80') }}; {% if item.server_name is defined %} server_name {{ item.server_name }}; From f319f9d1957916f38deeaf54110f4725d8d15a08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Sch=C3=B6ldstr=C3=B6m?= Date: Sat, 25 Mar 2017 15:29:15 -0500 Subject: [PATCH 06/26] Update docs --- README.md | 7 ++----- defaults/main.yml | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index c6375cb..d76df5b 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Available variables are listed below, along with default values (see `defaults/m nginx_vhosts: [] -A list of vhost definitions (server blocks) for Nginx virtual hosts. If left empty, you will need to supply your own virtual host configuration. See the commented example in `defaults/main.yml` for available server options. If you have a large number of customizations required for your server definition(s), you're likely better off managing the vhost configuration file yourself, leaving this variable set to `[]`. +A list of vhost definitions (server blocks) for Nginx virtual hosts. Each entry will create a separate config file named by `server_name`. If left empty, you will need to supply your own virtual host configuration. See the commented example in `defaults/main.yml` for available server options. If you have a large number of customizations required for your server definition(s), you're likely better off managing the vhost configuration file yourself, leaving this variable set to `[]`. nginx_vhosts: - listen: "80 default_server" @@ -26,6 +26,7 @@ A list of vhost definitions (server blocks) for Nginx virtual hosts. If left emp error_page: "" access_log: "" error_log: "" + state: "present" extra_parameters: | location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; @@ -43,10 +44,6 @@ Please take note of the indentation in the above block. The first line should be Whether to remove the 'default' virtualhost configuration supplied by Nginx. Useful if you want the base `/` URL to be directed at one of your own virtual hosts configured in a separate .conf file. - nginx_vhosts_filename: "vhosts.conf" - -The filename to use to store vhosts configuration. If you run the role multiple times (e.g. include the role with `with_items`), you can change the name for each run, effectively creating a separate vhosts file per vhost configuration. - nginx_upstreams: [] If you are configuring Nginx as a load balancer, you can define one or more upstream sets using this variable. In addition to defining at least one upstream, you would need to configure one of your server blocks to proxy requests through the defined upstream (e.g. `proxy_pass http://myapp1;`). See the commented example in `defaults/main.yml` for more information. diff --git a/defaults/main.yml b/defaults/main.yml index cd139d9..eb0d3b5 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -50,7 +50,6 @@ nginx_extra_http_options: "" # proxy_set_header Host $http_host; nginx_remove_default_vhost: false -nginx_vhosts_filename: "vhosts.conf" nginx_vhosts: [] # Example vhost below, showing all available options: # - listen: "80 default_server" # default: "80 default_server" @@ -63,6 +62,7 @@ nginx_vhosts: [] # access_log: "" # error_log: "" # extra_parameters: "" # Can be used to add extra config blocks (multiline). +# state: "absent" # To remove the vhost configuration. nginx_upstreams: [] # - name: myapp1 From b7b4a1cb4b574554b8f2b6abe2a3c1ce569cd9b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Sch=C3=B6ldstr=C3=B6m?= Date: Sat, 25 Mar 2017 14:19:08 -0500 Subject: [PATCH 07/26] Add integration test --- .travis.yml | 11 +++++++++++ tests/test.yml | 12 ++++++++++++ 2 files changed, 23 insertions(+) diff --git a/.travis.yml b/.travis.yml index 85eea53..352227a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,10 @@ env: - distro: ubuntu1204 script: + # Configure test script so we can run extra tests after playbook is run. + - export container_id=$(date +%s) + - export cleanup=false + # Download test shim. - wget -O ${PWD}/tests/test.sh https://gist.githubusercontent.com/geerlingguy/73ef1e5ee45d8694570f334be385e181/raw/ - chmod +x ${PWD}/tests/test.sh @@ -15,5 +19,12 @@ script: # Run tests. - ${PWD}/tests/test.sh + # Setup test site. + - 'docker exec ${container_id} mkdir -p /var/www/test' + - 'docker exec ${container_id} bash -c "echo Success >| /var/www/test/index.html"' + + # Make sure virtualhost exists. + - 'docker exec --tty ${container_id} env TERM=xterm curl http://test.dev/ | grep "Success"' + notifications: webhooks: https://galaxy.ansible.com/api/v1/notifications/ diff --git a/tests/test.yml b/tests/test.yml index 13426a9..32b4e09 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -3,6 +3,18 @@ vars: nginx_use_ppa: true + nginx_remove_default_vhost: true + nginx_vhosts: + - server_name: "test.dev" + root: "/var/www/test" + + pre_tasks: + - name: Update apt cache. + apt: update_cache=yes cache_valid_time=86400 + when: ansible_os_family == 'Debian' + + - name: Install dependencies. + package: name=curl roles: - role_under_test From 9cf49ac6c2fdf0b2da99483be848e361b687d7ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Sch=C3=B6ldstr=C3=B6m?= Date: Fri, 21 Apr 2017 07:46:45 -0500 Subject: [PATCH 08/26] when statements should not include jinja2 templating delimiters --- tasks/vhosts.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasks/vhosts.yml b/tasks/vhosts.yml index 9c4ef43..f89b8f2 100644 --- a/tasks/vhosts.yml +++ b/tasks/vhosts.yml @@ -20,7 +20,7 @@ owner: root group: root mode: 0644 - when: "{{ item.state|default('present') != 'absent' }}" + when: item.state|default('present') != 'absent' with_items: "{{ nginx_vhosts }}" notify: reload nginx @@ -28,6 +28,6 @@ file: path: "{{ nginx_vhost_path }}/{{ item.server_name.split(' ')[0] }}.conf" state: absent - when: "{{ item.state|default('present') == 'absent' }}" + when: item.state|default('present') == 'absent' with_items: "{{ nginx_vhosts }}" notify: reload nginx From 0d931c53c31652eb277f76e37ad57ba40da44abb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Sch=C3=B6ldstr=C3=B6m?= Date: Sat, 22 Apr 2017 10:03:18 -0500 Subject: [PATCH 09/26] Remove legacy vhosts.conf file --- tasks/vhosts.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tasks/vhosts.yml b/tasks/vhosts.yml index f89b8f2..8448503 100644 --- a/tasks/vhosts.yml +++ b/tasks/vhosts.yml @@ -31,3 +31,9 @@ when: item.state|default('present') == 'absent' with_items: "{{ nginx_vhosts }}" notify: reload nginx + +- name: Remove legacy vhosts.conf file. + file: + path: "{{ nginx_vhost_path }}/vhosts.conf" + state: absent + notify: reload nginx From 36cd4d3aec652a74871bc6b4edcb15ab2b7cdbde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Sch=C3=B6ldstr=C3=B6m?= Date: Sat, 25 Mar 2017 15:46:37 -0500 Subject: [PATCH 10/26] Allow users to extend config files through template inheritance --- defaults/main.yml | 3 +++ tasks/main.yml | 2 +- tasks/vhosts.yml | 2 +- templates/nginx.conf.j2 | 14 ++++++++++++++ templates/vhost.j2 | 15 +++++++++++++++ 5 files changed, 34 insertions(+), 2 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index eb0d3b5..68d60c1 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -12,6 +12,9 @@ nginx_ppa_version: stable # The name of the nginx apt/yum package to install. nginx_package_name: "nginx" +nginx_conf_template: "nginx.conf.j2" +nginx_vhost_template: "vhost.j2" + nginx_worker_processes: "{{ ansible_processor_vcpus | default(ansible_processor_count) }}" nginx_worker_connections: "1024" nginx_multi_accept: "off" diff --git a/tasks/main.yml b/tasks/main.yml index 6c420fe..74ca563 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -30,7 +30,7 @@ # Nginx setup. - name: Copy nginx configuration in place. template: - src: nginx.conf.j2 + src: "{{ nginx_conf_template }}" dest: "{{ nginx_conf_file_path }}" owner: root group: "{{ root_group }}" diff --git a/tasks/vhosts.yml b/tasks/vhosts.yml index 8448503..e6dd5f6 100644 --- a/tasks/vhosts.yml +++ b/tasks/vhosts.yml @@ -14,7 +14,7 @@ - name: Add managed vhost config files. template: - src: vhost.j2 + src: "{{ nginx_vhost_template }}" dest: "{{ nginx_vhost_path }}/{{ item.server_name.split(' ')[0] }}.conf" force: yes owner: root diff --git a/templates/nginx.conf.j2 b/templates/nginx.conf.j2 index 262e54a..4ec1de1 100644 --- a/templates/nginx.conf.j2 +++ b/templates/nginx.conf.j2 @@ -3,18 +3,25 @@ user {{ nginx_user }}; error_log {{ nginx_error_log }}; pid {{ nginx_pidfile }}; +{% block worker %} worker_processes {{ nginx_worker_processes }}; +{% endblock %} +{% block events %} events { worker_connections {{ nginx_worker_connections }}; multi_accept {{ nginx_multi_accept }}; } +{% endblock %} {% if nginx_extra_conf_options %} {{ nginx_extra_conf_options }} {% endif %} http { + {% block http_begin %}{% endblock %} + +{% block http_basic %} include {{ nginx_mime_file_path }}; default_type application/octet-stream; @@ -39,11 +46,13 @@ http { {% if nginx_proxy_cache_path %} proxy_cache_path {{ nginx_proxy_cache_path }}; {% endif %} +{% endblock %} {% if nginx_extra_http_options %} {{ nginx_extra_http_options|indent(4, False) }} {% endif %} +{% block http_upstream %} {% for upstream in nginx_upstreams %} upstream {{ upstream.name }} { {% if upstream.strategy is defined %} @@ -57,9 +66,14 @@ http { {% endif %} } {% endfor %} +{% endblock %} +{% block http_includes %} include {{ nginx_conf_path }}/*.conf; {% if nginx_conf_path != nginx_vhost_path %} include {{ nginx_vhost_path }}/*; {% endif %} +{% endblock %} + + {% block http_end %}{% endblock %} } diff --git a/templates/vhost.j2 b/templates/vhost.j2 index 35e3de1..40beced 100644 --- a/templates/vhost.j2 +++ b/templates/vhost.j2 @@ -1,4 +1,16 @@ +{% block server_redirect %} +{% if item.server_name_redirect is defined %} + listen {{ item.listen | default('80') }}; + server_name {{ item.server_name_redirect }}; + return 301 $scheme://{{ item.server_name.split(' ')[0] }}$request_uri; +} +{% endif %} +{% endblock %} + server { + {% block server_begin %}{% endblock %} + + {% block server_basic -%} listen {{ item.listen | default('80') }}; {% if item.server_name is defined %} @@ -24,6 +36,9 @@ server { {% if item.return is defined %} return {{ item.return }}; {% endif %} + {% endblock %} + + {% block server_end %}{% endblock %} {% if item.extra_parameters is defined %} {{ item.extra_parameters|indent(4) }} From c9a60152814140d17c32a0cc2940a4b5c4b7c09f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Sch=C3=B6ldstr=C3=B6m?= Date: Sat, 25 Mar 2017 16:45:01 -0500 Subject: [PATCH 11/26] move gzip to separate block as it's pretty common to override --- templates/nginx.conf.j2 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/templates/nginx.conf.j2 b/templates/nginx.conf.j2 index 4ec1de1..cb187d8 100644 --- a/templates/nginx.conf.j2 +++ b/templates/nginx.conf.j2 @@ -41,13 +41,15 @@ http { keepalive_requests {{ nginx_keepalive_requests }}; server_tokens {{ nginx_server_tokens }}; - #gzip on; - {% if nginx_proxy_cache_path %} proxy_cache_path {{ nginx_proxy_cache_path }}; {% endif %} {% endblock %} +{% block http_gzip %} + # gzip on; +{% endblock %} + {% if nginx_extra_http_options %} {{ nginx_extra_http_options|indent(4, False) }} {% endif %} From 125cc7a8843af522019126f82bc71bfba2b07ee0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Sch=C3=B6ldstr=C3=B6m?= Date: Sat, 22 Apr 2017 17:10:05 -0500 Subject: [PATCH 12/26] Add template inheritance docs [ci skip] --- README.md | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/README.md b/README.md index d76df5b..6d46b94 100644 --- a/README.md +++ b/README.md @@ -121,6 +121,58 @@ Configures Nginx's [`log_format`](http://nginx.org/en/docs/http/ngx_http_log_mod (For RedHat/CentOS only) Set this to `false` to disable the installation of the `nginx` yum repository. This could be necessary if you want the default OS stable packages, or if you use Satellite. +## Overriding configuration templates + +If you can't customize via variables because an option isn't exposed, you can override the template used to generate the virtualhost configuration files or the `nginx.conf` file. + +```yaml +nginx_conf_template: "nginx.conf.j2" +nginx_vhost_template: "vhost.j2" +``` + +You can either copy and modify the provided template, or extend it with [Jinja2 template inheritance](http://jinja.pocoo.org/docs/2.9/templates/#template-inheritance) and override the specific template block you need to change. + +### Example: Configure gzip in nginx configuration + +Set the `nginx_conf_template` to point to a template file in your playbook directory. + +```yaml +nginx_conf_template: "{{ playbook_dir }}/templates/nginx.conf.j2" +``` + +Create the child template in the path you configured above and extend `geerlingguy.nginx` template file relative to your `playbook.yml`. + +``` +{% extends 'roles/geerlingguy.nginx/templates/nginx.conf.j2' %} + +{% block http_gzip %} + gzip on; + gzip_proxied any; + gzip_static on; + gzip_http_version 1.0; + gzip_disable "MSIE [1-6]\."; + gzip_vary on; + gzip_comp_level 6; + gzip_types + text/plain + text/css + text/xml + text/javascript + application/javascript + application/x-javascript + application/json + application/xml + application/xml+rss + application/xhtml+xml + application/x-font-ttf + application/x-font-opentype + image/svg+xml + image/x-icon; + gzip_buffers 16 8k; + gzip_min_length 512; +{% endblock %} +``` + ## Dependencies None. From 5e41c6b1f91924402b7f39d53ad6dd0118321291 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Sch=C3=B6ldstr=C3=B6m?= Date: Wed, 26 Apr 2017 19:36:32 -0500 Subject: [PATCH 13/26] Issue #95: Add support for setting template on a per vhost basis --- README.md | 16 ++++++++++++++++ defaults/main.yml | 1 + tasks/vhosts.yml | 2 +- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6d46b94..2e4a2d6 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ A list of vhost definitions (server blocks) for Nginx virtual hosts. Each entry access_log: "" error_log: "" state: "present" + template: "{{ nginx_vhost_template }}" extra_parameters: | location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; @@ -130,6 +131,21 @@ nginx_conf_template: "nginx.conf.j2" nginx_vhost_template: "vhost.j2" ``` +If necessary you can also set the template on a per vhost basis. + +```yaml +nginx_vhosts: + - listen: "80 default_server" + server_name: "site1.example.com" + root: "/var/www/site1.example.com" + index: "index.php index.html index.htm" + template: "{{ playbook_dir }}/templates/site1.example.com.vhost.j2" + - server_name: "site2.example.com" + root: "/var/www/site2.example.com" + index: "index.php index.html index.htm" + template: "{{ playbook_dir }}/templates/site2.example.com.vhost.j2" +``` + You can either copy and modify the provided template, or extend it with [Jinja2 template inheritance](http://jinja.pocoo.org/docs/2.9/templates/#template-inheritance) and override the specific template block you need to change. ### Example: Configure gzip in nginx configuration diff --git a/defaults/main.yml b/defaults/main.yml index 68d60c1..5161e82 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -65,6 +65,7 @@ nginx_vhosts: [] # access_log: "" # error_log: "" # extra_parameters: "" # Can be used to add extra config blocks (multiline). +# template: "" # Can be used to override the `nginx_vhost_template` per host. # state: "absent" # To remove the vhost configuration. nginx_upstreams: [] diff --git a/tasks/vhosts.yml b/tasks/vhosts.yml index e6dd5f6..03c32d9 100644 --- a/tasks/vhosts.yml +++ b/tasks/vhosts.yml @@ -14,7 +14,7 @@ - name: Add managed vhost config files. template: - src: "{{ nginx_vhost_template }}" + src: "{{ item.template|default(nginx_vhost_template) }}" dest: "{{ nginx_vhost_path }}/{{ item.server_name.split(' ')[0] }}.conf" force: yes owner: root From 235a0053a759ca9f0d7d35a0775cb60f4d7e5a49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Sch=C3=B6ldstr=C3=B6m?= Date: Sat, 3 Jun 2017 08:46:33 -0500 Subject: [PATCH 14/26] Document missing nginx_vhost parameters --- README.md | 1 + defaults/main.yml | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2e4a2d6..7c18ed7 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ A list of vhost definitions (server blocks) for Nginx virtual hosts. Each entry nginx_vhosts: - listen: "80 default_server" server_name: "example.com" + server_name_redirect: "www.example.com" root: "/var/www/example.com" index: "index.php index.html index.htm" error_page: "" diff --git a/defaults/main.yml b/defaults/main.yml index 5161e82..9851f06 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -55,8 +55,9 @@ nginx_extra_http_options: "" nginx_remove_default_vhost: false nginx_vhosts: [] # Example vhost below, showing all available options: -# - listen: "80 default_server" # default: "80 default_server" +# - listen: "80" # default: "80" # server_name: "example.com" # default: N/A +# server_name_redirect: "www.example.com" # default: N/A # root: "/var/www/example.com" # default: N/A # index: "index.html index.htm" # default: "index.html index.htm" # From 98b736f4792a35d1b50a7c3111a48d29088c52cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Sch=C3=B6ldstr=C3=B6m?= Date: Sat, 3 Jun 2017 08:48:00 -0500 Subject: [PATCH 15/26] Add optional vhost_filename option to nginx_vhosts --- README.md | 1 + defaults/main.yml | 1 + tasks/vhosts.yml | 4 ++-- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7c18ed7..fd29db5 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ A list of vhost definitions (server blocks) for Nginx virtual hosts. Each entry error_log: "" state: "present" template: "{{ nginx_vhost_template }}" + vhost_filename: "example.com.conf" extra_parameters: | location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; diff --git a/defaults/main.yml b/defaults/main.yml index 9851f06..a7a4db4 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -60,6 +60,7 @@ nginx_vhosts: [] # server_name_redirect: "www.example.com" # default: N/A # root: "/var/www/example.com" # default: N/A # index: "index.html index.htm" # default: "index.html index.htm" +# vhost_filename: "example.com.conf" # Can be used to set the filename of the vhost file. # # # Properties that are only added if defined: # error_page: "" diff --git a/tasks/vhosts.yml b/tasks/vhosts.yml index 03c32d9..e7bd642 100644 --- a/tasks/vhosts.yml +++ b/tasks/vhosts.yml @@ -15,7 +15,7 @@ - name: Add managed vhost config files. template: src: "{{ item.template|default(nginx_vhost_template) }}" - dest: "{{ nginx_vhost_path }}/{{ item.server_name.split(' ')[0] }}.conf" + dest: "{{ nginx_vhost_path }}/{{ item.vhost_filename|default(item.server_name.split(' ')[0] ~ '.conf') }}" force: yes owner: root group: root @@ -26,7 +26,7 @@ - name: Remove managed vhost config files. file: - path: "{{ nginx_vhost_path }}/{{ item.server_name.split(' ')[0] }}.conf" + path: "{{ nginx_vhost_path }}/{{ item.vhost_filename|default(item.server_name.split(' ')[0] ~ '.conf') }}" state: absent when: item.state|default('present') == 'absent' with_items: "{{ nginx_vhosts }}" From 4c5df1faea645551c0655c96209b683ee44ff20b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Sch=C3=B6ldstr=C3=B6m?= Date: Sat, 3 Jun 2017 08:49:55 -0500 Subject: [PATCH 16/26] Change README vhost example for the common SSL option with a http redirect --- README.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fd29db5..1103c8c 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Available variables are listed below, along with default values (see `defaults/m A list of vhost definitions (server blocks) for Nginx virtual hosts. Each entry will create a separate config file named by `server_name`. If left empty, you will need to supply your own virtual host configuration. See the commented example in `defaults/main.yml` for available server options. If you have a large number of customizations required for your server definition(s), you're likely better off managing the vhost configuration file yourself, leaving this variable set to `[]`. nginx_vhosts: - - listen: "80 default_server" + - listen: "443 ssl http2" server_name: "example.com" server_name_redirect: "www.example.com" root: "/var/www/example.com" @@ -38,11 +38,24 @@ A list of vhost definitions (server blocks) for Nginx virtual hosts. Each entry fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } + ssl_certificate /etc/ssl/certs/ssl-cert-snakeoil.pem; + ssl_certificate_key /etc/ssl/private/ssl-cert-snakeoil.key; + ssl_protocols TLSv1.1 TLSv1.2; + ssl_ciphers HIGH:!aNULL:!MD5; An example of a fully-populated nginx_vhosts entry, using a `|` to declare a block of syntax for the `extra_parameters`. Please take note of the indentation in the above block. The first line should be a normal 2-space indent. All other lines should be indented normally relative to that line. In the generated file, the entire block will be 4-space indented. This style will ensure the config file is indented correctly. + - listen: "80" + server_name: "example.com www.example.com" + return "301 https://example.com$request_uri;" + vhost_filename: "example.com.80.conf" + +An example of a secondary vhost which will redirect to the one shown above. + +*Note: The `vhost_filename` defaults to the first domain in `server_name`, if you have two vhosts with the same domain, eg. a redirect, you need to manually set the `vhost_filename` so the second one doesn't override the first one* + nginx_remove_default_vhost: false Whether to remove the 'default' virtualhost configuration supplied by Nginx. Useful if you want the base `/` URL to be directed at one of your own virtual hosts configured in a separate .conf file. From d227a1803c5b69059a3dc9974cb4569011802a20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Sch=C3=B6ldstr=C3=B6m?= Date: Sat, 3 Jun 2017 08:56:03 -0500 Subject: [PATCH 17/26] server_name_redirect is only added if defined --- defaults/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/defaults/main.yml b/defaults/main.yml index a7a4db4..fff97c9 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -57,12 +57,12 @@ nginx_vhosts: [] # Example vhost below, showing all available options: # - listen: "80" # default: "80" # server_name: "example.com" # default: N/A -# server_name_redirect: "www.example.com" # default: N/A # root: "/var/www/example.com" # default: N/A # index: "index.html index.htm" # default: "index.html index.htm" # vhost_filename: "example.com.conf" # Can be used to set the filename of the vhost file. # # # Properties that are only added if defined: +# server_name_redirect: "www.example.com" # default: N/A # error_page: "" # access_log: "" # error_log: "" From 7b47c3de1243d3868b9eea780d6ae4687753f56f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Sch=C3=B6ldstr=C3=B6m?= Date: Sat, 3 Jun 2017 09:01:09 -0500 Subject: [PATCH 18/26] vhost_filename -> filename --- README.md | 6 +++--- defaults/main.yml | 2 +- tasks/vhosts.yml | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 1103c8c..5a5f668 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ A list of vhost definitions (server blocks) for Nginx virtual hosts. Each entry error_log: "" state: "present" template: "{{ nginx_vhost_template }}" - vhost_filename: "example.com.conf" + filename: "example.com.conf" extra_parameters: | location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; @@ -50,11 +50,11 @@ Please take note of the indentation in the above block. The first line should be - listen: "80" server_name: "example.com www.example.com" return "301 https://example.com$request_uri;" - vhost_filename: "example.com.80.conf" + filename: "example.com.80.conf" An example of a secondary vhost which will redirect to the one shown above. -*Note: The `vhost_filename` defaults to the first domain in `server_name`, if you have two vhosts with the same domain, eg. a redirect, you need to manually set the `vhost_filename` so the second one doesn't override the first one* +*Note: The `filename` defaults to the first domain in `server_name`, if you have two vhosts with the same domain, eg. a redirect, you need to manually set the `filename` so the second one doesn't override the first one* nginx_remove_default_vhost: false diff --git a/defaults/main.yml b/defaults/main.yml index fff97c9..b21140b 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -59,7 +59,7 @@ nginx_vhosts: [] # server_name: "example.com" # default: N/A # root: "/var/www/example.com" # default: N/A # index: "index.html index.htm" # default: "index.html index.htm" -# vhost_filename: "example.com.conf" # Can be used to set the filename of the vhost file. +# filename: "example.com.conf" # Can be used to set the filename of the vhost file. # # # Properties that are only added if defined: # server_name_redirect: "www.example.com" # default: N/A diff --git a/tasks/vhosts.yml b/tasks/vhosts.yml index e7bd642..05af037 100644 --- a/tasks/vhosts.yml +++ b/tasks/vhosts.yml @@ -15,7 +15,7 @@ - name: Add managed vhost config files. template: src: "{{ item.template|default(nginx_vhost_template) }}" - dest: "{{ nginx_vhost_path }}/{{ item.vhost_filename|default(item.server_name.split(' ')[0] ~ '.conf') }}" + dest: "{{ nginx_vhost_path }}/{{ item.filename|default(item.server_name.split(' ')[0] ~ '.conf') }}" force: yes owner: root group: root @@ -26,7 +26,7 @@ - name: Remove managed vhost config files. file: - path: "{{ nginx_vhost_path }}/{{ item.vhost_filename|default(item.server_name.split(' ')[0] ~ '.conf') }}" + path: "{{ nginx_vhost_path }}/{{ item.filename|default(item.server_name.split(' ')[0] ~ '.conf') }}" state: absent when: item.state|default('present') == 'absent' with_items: "{{ nginx_vhosts }}" From 3a06154e76c720f2971665a844e0eacddc7a9022 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Sch=C3=B6ldstr=C3=B6m?= Date: Sat, 3 Jun 2017 09:06:23 -0500 Subject: [PATCH 19/26] fix ubuntu tests using ansible-role-elasticsearch as example --- tests/test.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/test.yml b/tests/test.yml index 32b4e09..9ae8960 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -10,11 +10,12 @@ pre_tasks: - name: Update apt cache. - apt: update_cache=yes cache_valid_time=86400 + apt: update_cache=yes cache_valid_time=600 when: ansible_os_family == 'Debian' + changed_when: false - name: Install dependencies. - package: name=curl + package: name=curl state=present roles: - role_under_test From 58645502b486ad601377a7cd3b09b71458db4d64 Mon Sep 17 00:00:00 2001 From: Lioman Date: Wed, 7 Jun 2017 09:52:27 +0200 Subject: [PATCH 20/26] Update vhost.j2 Add missing server { to vhost template --- templates/vhost.j2 | 1 + 1 file changed, 1 insertion(+) diff --git a/templates/vhost.j2 b/templates/vhost.j2 index 40beced..54ffefd 100644 --- a/templates/vhost.j2 +++ b/templates/vhost.j2 @@ -1,3 +1,4 @@ +server { {% block server_redirect %} {% if item.server_name_redirect is defined %} listen {{ item.listen | default('80') }}; From 7e0a33c492de072cfe8ff99405c795592b7b94a7 Mon Sep 17 00:00:00 2001 From: Lioman Date: Wed, 7 Jun 2017 10:35:26 +0200 Subject: [PATCH 21/26] Update vhost.j2 move "server {" to if block --- templates/vhost.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/vhost.j2 b/templates/vhost.j2 index 54ffefd..0feb602 100644 --- a/templates/vhost.j2 +++ b/templates/vhost.j2 @@ -1,6 +1,6 @@ -server { {% block server_redirect %} {% if item.server_name_redirect is defined %} +server { listen {{ item.listen | default('80') }}; server_name {{ item.server_name_redirect }}; return 301 $scheme://{{ item.server_name.split(' ')[0] }}$request_uri; From 08fbab26bd03bd5faa131a9991be97793686807e Mon Sep 17 00:00:00 2001 From: Ben McClure Date: Mon, 12 Jun 2017 19:41:39 -0500 Subject: [PATCH 22/26] Added nginx support --- defaults/main.yml | 2 +- tasks/main.yml | 3 +++ tasks/setup-Archlinux.yml | 5 +++++ vars/Archlinux.yml | 9 +++++++++ 4 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 tasks/setup-Archlinux.yml create mode 100644 vars/Archlinux.yml diff --git a/defaults/main.yml b/defaults/main.yml index b21140b..38aa3da 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -9,7 +9,7 @@ nginx_yum_repo_enabled: true nginx_ppa_use: false nginx_ppa_version: stable -# The name of the nginx apt/yum package to install. +# The name of the nginx package to install. nginx_package_name: "nginx" nginx_conf_template: "nginx.conf.j2" diff --git a/tasks/main.yml b/tasks/main.yml index 74ca563..4ee901a 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -24,6 +24,9 @@ - include: setup-OpenBSD.yml when: ansible_os_family == 'OpenBSD' +- include: setup-Archlinux.yml + when: ansible_os_family == 'Archlinux' + # Vhost configuration. - include: vhosts.yml diff --git a/tasks/setup-Archlinux.yml b/tasks/setup-Archlinux.yml new file mode 100644 index 0000000..2aa89ec --- /dev/null +++ b/tasks/setup-Archlinux.yml @@ -0,0 +1,5 @@ +--- +- name: Ensure nginx is installed. + pacman: + name: "{{ nginx_package_name }}" + state: installed diff --git a/vars/Archlinux.yml b/vars/Archlinux.yml new file mode 100644 index 0000000..593e100 --- /dev/null +++ b/vars/Archlinux.yml @@ -0,0 +1,9 @@ +--- +root_group: root +nginx_conf_path: /etc/nginx/conf.d +nginx_conf_file_path: /etc/nginx/nginx.conf +nginx_mime_file_path: /etc/nginx/mime.types +nginx_pidfile: /run/nginx.pid +nginx_vhost_path: /etc/nginx/sites-enabled +nginx_default_vhost_path: /etc/nginx/sites-enabled/default +__nginx_user: "http" From 3a8af3906ef5f32c33eeeca4cb4b1be6ed57a3e5 Mon Sep 17 00:00:00 2001 From: Ben McClure Date: Mon, 12 Jun 2017 20:06:31 -0500 Subject: [PATCH 23/26] Update readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5a5f668..e351682 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,9 @@ [![Build Status](https://travis-ci.org/geerlingguy/ansible-role-nginx.svg?branch=master)](https://travis-ci.org/geerlingguy/ansible-role-nginx) -Installs Nginx on RedHat/CentOS or Debian/Ubuntu Linux, FreeBSD or OpenBSD servers. +Installs Nginx on RedHat/CentOS, Debian/Ubuntu, Archlinux, FreeBSD or OpenBSD servers. -This role installs and configures the latest version of Nginx from the Nginx yum repository (on RedHat-based systems) or via apt (on Debian-based systems) or pkgng (on FreeBSD systems) or pkg_add (on OpenBSD systems). You will likely need to do extra setup work after this role has installed Nginx, like adding your own [virtualhost].conf file inside `/etc/nginx/conf.d/`, describing the location and options to use for your particular website. +This role installs and configures the latest version of Nginx from the Nginx yum repository (on RedHat-based systems) or via apt (on Debian-based systems) or pacman (Archlinux) or pkgng (on FreeBSD systems) or pkg_add (on OpenBSD systems). You will likely need to do extra setup work after this role has installed Nginx, like adding your own [virtualhost].conf file inside `/etc/nginx/conf.d/`, describing the location and options to use for your particular website. ## Requirements From 1597d0104b97704e2ab9ca1935a2eeef4070c446 Mon Sep 17 00:00:00 2001 From: Ben McClure Date: Mon, 12 Jun 2017 20:23:57 -0500 Subject: [PATCH 24/26] Add Archlinux support to meta info --- meta/main.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/meta/main.yml b/meta/main.yml index a7f79fc..9418877 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -18,6 +18,9 @@ galaxy_info: - name: Ubuntu versions: - all + - name: Archlinux + versions: + - all - name: FreeBSD versions: - 10.3 From b7606808f6e87473abb157f303ffc146f594fab4 Mon Sep 17 00:00:00 2001 From: Jeff Geerling Date: Tue, 13 Jun 2017 16:23:57 -0500 Subject: [PATCH 25/26] PR #109 follow-up: Clean up description in README. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e351682..9e4edb3 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Installs Nginx on RedHat/CentOS, Debian/Ubuntu, Archlinux, FreeBSD or OpenBSD servers. -This role installs and configures the latest version of Nginx from the Nginx yum repository (on RedHat-based systems) or via apt (on Debian-based systems) or pacman (Archlinux) or pkgng (on FreeBSD systems) or pkg_add (on OpenBSD systems). You will likely need to do extra setup work after this role has installed Nginx, like adding your own [virtualhost].conf file inside `/etc/nginx/conf.d/`, describing the location and options to use for your particular website. +This role installs and configures the latest version of Nginx from the Nginx yum repository (on RedHat-based systems), apt (on Debian-based systems), pacman (Archlinux), pkgng (on FreeBSD systems) or pkg_add (on OpenBSD systems). You will likely need to do extra setup work after this role has installed Nginx, like adding your own [virtualhost].conf file inside `/etc/nginx/conf.d/`, describing the location and options to use for your particular website. ## Requirements From 97b91034c08b39357ea1df11f9dca6e1f6ebb78e Mon Sep 17 00:00:00 2001 From: minitux Date: Fri, 30 Jun 2017 10:10:49 +0200 Subject: [PATCH 26/26] Fix syntax in README Fix return un vhost redirect --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9e4edb3..aa8c3ab 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ Please take note of the indentation in the above block. The first line should be - listen: "80" server_name: "example.com www.example.com" - return "301 https://example.com$request_uri;" + return: "301 https://example.com$request_uri" filename: "example.com.80.conf" An example of a secondary vhost which will redirect to the one shown above.