From 9b790683805203fd9ce643af3811a020961a0265 Mon Sep 17 00:00:00 2001 From: Salt Date: Sat, 18 Sep 2021 07:19:26 -0500 Subject: [PATCH] Allow for the definition of a singular proxy_pass on ingress_servers to simplify configuration --- playbooks/prod_web.yml | 40 +++++++------------------- roles/ingress/templates/vhosts.conf.j2 | 9 +++++- 2 files changed, 18 insertions(+), 31 deletions(-) diff --git a/playbooks/prod_web.yml b/playbooks/prod_web.yml index 00d9044..36048c4 100755 --- a/playbooks/prod_web.yml +++ b/playbooks/prod_web.yml @@ -55,20 +55,14 @@ ingress_servers: # desu.ltd - name: desu.ltd - proxies: - - location: / - pass: http://desultd:80 + proxy_pass: http://desultd:80 - name: git.desu.ltd - proxies: - - location: / - pass: http://gitea:3000 + proxy_pass: http://gitea:3000 - name: nc.desu.ltd directives: - "add_header Strict-Transport-Security \"max-age=31536000\"" - "client_max_body_size 0" - proxies: - - location: / - pass: http://nextcloud:80 + proxy_pass: http://nextcloud:80 locations: - location: "^~ /.well-known" contents: | @@ -81,13 +75,9 @@ directives: - "return 301 $scheme://9iron.club$request_uri" - name: 9iron.club - proxies: - - location: / - pass: http://9iron:80 + proxy_pass: http://9iron:80 - name: srv.9iron.club - proxies: - - location: / - pass: http://srv:80 + proxy_pass: http://srv:80 tags: [ web, docker, ingress ] - hosts: web2.desu.ltd module_defaults: @@ -125,13 +115,9 @@ vars: ingress_servers: - name: cowfee.moe - proxies: - - location: / - pass: http://pleroma:4000 + proxy_pass: http://pleroma:4000 - name: tube.cowfee.moe - proxies: - - location: / - pass: http://peertube:9000 + proxy_pass: http://peertube:9000 tags: [ web, docker, ingress ] - hosts: web3.desu.ltd module_defaults: @@ -169,15 +155,9 @@ vars: ingress_servers: - name: netbox.desu.ltd - proxies: - - location: / - pass: http://netbox:8080 + proxy_pass: http://netbox:8080 - name: nagios.desu.ltd - proxies: - - location: / - pass: http://nagios:80 + proxy_pass: http://nagios:80 - name: movie.desu.ltd - proxies: - - location: / - pass: http://movienight:8089 + proxy_pass: http://movienight:8089 tags: [ web, docker, ingress ] diff --git a/roles/ingress/templates/vhosts.conf.j2 b/roles/ingress/templates/vhosts.conf.j2 index b038144..633cbe6 100644 --- a/roles/ingress/templates/vhosts.conf.j2 +++ b/roles/ingress/templates/vhosts.conf.j2 @@ -22,7 +22,14 @@ server { {% endfor %} {% endif %} -{% if server.proxies is defined %} +{% if server.proxy_pass is defined %} + # Singular proxy_pass + location / { + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_pass {{ server.proxy_pass }}; + } +{% elif server.proxies is defined %} # Proxy locations {% for proxy in server.proxies %} location {{ proxy.location }} {