From 8b75c49917c5f45f94d992be76284efe90efa088 Mon Sep 17 00:00:00 2001 From: Felix Stupp Date: Tue, 31 Dec 2019 16:30:42 +0100 Subject: [PATCH] nginx/proxy: Made dependent on nginx/server and allowed additional directives --- roles/nginx/proxy/defaults/main.yml | 1 + roles/nginx/proxy/meta/main.yml | 4 +++- roles/nginx/proxy/tasks/main.yml | 10 ---------- .../proxy/{templates/proxy.conf => vars/main.yml} | 14 +++----------- 4 files changed, 7 insertions(+), 22 deletions(-) delete mode 100644 roles/nginx/proxy/tasks/main.yml rename roles/nginx/proxy/{templates/proxy.conf => vars/main.yml} (59%) diff --git a/roles/nginx/proxy/defaults/main.yml b/roles/nginx/proxy/defaults/main.yml index 2237cfc..3ba5f9e 100644 --- a/roles/nginx/proxy/defaults/main.yml +++ b/roles/nginx/proxy/defaults/main.yml @@ -3,3 +3,4 @@ # domain: example.com # backend_port: 12345 OR backend_socket: /example.socket # upstream_name (optional) +additional_directives: "" diff --git a/roles/nginx/proxy/meta/main.yml b/roles/nginx/proxy/meta/main.yml index f152e4b..30b6167 100644 --- a/roles/nginx/proxy/meta/main.yml +++ b/roles/nginx/proxy/meta/main.yml @@ -3,6 +3,8 @@ allow_duplicates: yes dependencies: - - role: acme/certificate - role: nginx/upstream # upstream_name + - role: nginx/server + # domain + # directives diff --git a/roles/nginx/proxy/tasks/main.yml b/roles/nginx/proxy/tasks/main.yml deleted file mode 100644 index 2244741..0000000 --- a/roles/nginx/proxy/tasks/main.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- - -- name: Configure proxy for {{ domain }} to {{ backend_port is defined | ternary(backend_port, backend_socket) }} - template: - src: proxy.conf - dest: "{{ nginx_sites_directory }}/{{ domain }}" - owner: root - group: root - mode: "u=rw,g=r,o=r" - notify: reload nginx diff --git a/roles/nginx/proxy/templates/proxy.conf b/roles/nginx/proxy/vars/main.yml similarity index 59% rename from roles/nginx/proxy/templates/proxy.conf rename to roles/nginx/proxy/vars/main.yml index 243c3b6..2ecc098 100644 --- a/roles/nginx/proxy/templates/proxy.conf +++ b/roles/nginx/proxy/vars/main.yml @@ -1,14 +1,7 @@ -server { - listen 443 ssl http2; - listen [::]:443 ssl http2; - server_name {{ domain }}; +--- - ssl on; - ssl_certificate {{ acme_certificate_location }}; - ssl_certificate_key {{ acme_key_location }}; - - include {{ nginx_snippets_directory }}/https; - include {{ nginx_snippets_directory }}/global; +directives: | + {{ additional_directives }} location / { proxy_pass http://{{ upstream_name }}; @@ -22,4 +15,3 @@ server { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } -}