From abb222d7d13b448fdb5449f0f28123f3800e4e87 Mon Sep 17 00:00:00 2001 From: Joel Johnston Date: Sat, 7 Oct 2023 14:30:46 -0600 Subject: [PATCH] Enhance nginx config for better troubleshooting --- cicd/Ansible-Playbook-Gateway-Configure.yml | 7 +++- gateway/joeljca.site.blue | 37 +++++++++++++++++++-- gateway/joeljca.site.green | 37 +++++++++++++++++++-- 3 files changed, 76 insertions(+), 5 deletions(-) diff --git a/cicd/Ansible-Playbook-Gateway-Configure.yml b/cicd/Ansible-Playbook-Gateway-Configure.yml index e88695c..640b69c 100644 --- a/cicd/Ansible-Playbook-Gateway-Configure.yml +++ b/cicd/Ansible-Playbook-Gateway-Configure.yml @@ -5,4 +5,9 @@ name: '{{ inventory_hostname }}' - name: install nginx - apt: name=nginx \ No newline at end of file + apt: name=nginx + + - name: Remove default site + file: + path: "/etc/nginx/sites-enabled/default" + state: absent \ No newline at end of file diff --git a/gateway/joeljca.site.blue b/gateway/joeljca.site.blue index 48728da..c5ae426 100644 --- a/gateway/joeljca.site.blue +++ b/gateway/joeljca.site.blue @@ -1,6 +1,11 @@ server { - listen 80; - listen [::]:80; + listen 80 default_server; + server_name www.joelj.ca joelj.ca; + return 301 https://www.joelj.ca$request_uri; +} + +server { + add_header X-Origin-LB $hostname; # SSL configuration # @@ -13,4 +18,32 @@ server { location / { proxy_pass http://joeljcablue; } +} + +server { + # SSL configuration + # + listen 443 ssl; + ssl_certificate /etc/ssl/certs/joeljca-2022.crt; + ssl_certificate_key /etc/ssl/certs/joeljca-2022.rsa; + + server_name wwwblue.joelj.ca; + + location / { + proxy_pass http://joeljcablue; + } +} + +server { + # SSL configuration + # + listen 443 ssl; + ssl_certificate /etc/ssl/certs/joeljca-2022.crt; + ssl_certificate_key /etc/ssl/certs/joeljca-2022.rsa; + + server_name wwwgreen.joelj.ca; + + location / { + proxy_pass http://joeljcagreen; + } } \ No newline at end of file diff --git a/gateway/joeljca.site.green b/gateway/joeljca.site.green index 53c3578..76ef694 100644 --- a/gateway/joeljca.site.green +++ b/gateway/joeljca.site.green @@ -1,6 +1,11 @@ server { - listen 80; - listen [::]:80; + listen 80 default_server; + server_name www.joelj.ca joelj.ca; + return 301 https://www.joelj.ca$request_uri; +} + +server { + add_header X-Origin-LB $hostname; # SSL configuration # @@ -10,6 +15,34 @@ server { server_name www.joelj.ca joelj.ca; + location / { + proxy_pass http://joeljcagreen; + } +} + +server { + # SSL configuration + # + listen 443 ssl; + ssl_certificate /etc/ssl/certs/joeljca-2022.crt; + ssl_certificate_key /etc/ssl/certs/joeljca-2022.rsa; + + server_name wwwblue.joelj.ca; + + location / { + proxy_pass http://joeljcablue; + } +} + +server { + # SSL configuration + # + listen 443 ssl; + ssl_certificate /etc/ssl/certs/joeljca-2022.crt; + ssl_certificate_key /etc/ssl/certs/joeljca-2022.rsa; + + server_name wwwgreen.joelj.ca; + location / { proxy_pass http://joeljcagreen; }