srobo / ansible

Ansible configuration for Student Robotics' pet machines
MIT License
0 stars 5 forks source link

Fix proxied url hostnames and thus code-submitter urls #59

Closed PeterJCLaw closed 10 months ago

PeterJCLaw commented 10 months ago

Summary

There's been a long-standing issue where the hosted code-submitter emits urls which point at the machine hosting it, leading to users ending up on that domain rather than on our root domain.

The two previously observed failure modes were:

This PR fixes the issue by:

This is approximately the same fix as was attempted in https://github.com/srobo/ansible/pull/37, however it seems that that PR didn't work due to the mismatch of types in the secondary_hostnames value (it's now a list, was presumably a string previously).

Code review

Reviewing the changes by commit may be useful.

Testing

TASK [srobo-nginx : Copy our configuration] ******************************************
--- before: /etc/nginx/nginx.conf
+++ after: /home/peter/.ansible/tmp/ansible-local-625847yb79663/tmp4s_nyuqn/nginx.conf
@@ -113,7 +113,8 @@
         # starting up, even if in a degraded mode.
         set $competitorsvcs 'competitorsvcs.studentrobotics.org';
         proxy_pass https://$competitorsvcs/code-submitter/;
-        proxy_set_header Host $competitorsvcs;
+        # Note: don't set a Host header as we want the code-submitter to use our
+        # public hostname, not the hostname of the underlying machine.
       }

         # Provide access to the competition pages under the normal prefix

changed: [monty.studentrobotics.org]
TASK [competitor-services-nginx : Copy our configuration] ****************************
--- before: /etc/nginx/nginx.conf
+++ after: /home/peter/.ansible/tmp/ansible-local-625847yb79663/tmpz44efhua/nginx.conf
@@ -61,7 +61,7 @@
     # several server blocks can listen to the same port).
     listen         443 ssl;
     listen         [::]:443 ssl;
-    server_name    competitorsvcs.studentrobotics.org ['studentrobotics.org'];
+    server_name    competitorsvcs.studentrobotics.org studentrobotics.org ;
     root           /var/www;

     proxy_pass_request_headers on;

changed: [competitorsvcs.studentrobotics.org]

Links

Extra context: https://github.com/PeterJCLaw/code-submitter/issues/31