Merge ~troyanov/maas:rackd-nginx-conf into maas:master

Proposed by Anton Troyanov
Status: Merged
Approved by: Anton Troyanov
Approved revision: a4c11bd4133dbfe0356e45bf1c17b99f2b8bf5cc
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~troyanov/maas:rackd-nginx-conf
Merge into: maas:master
Diff against target: 16 lines (+2/-2)
1 file modified
src/provisioningserver/templates/http/rackd.nginx.conf.template (+2/-2)
Reviewer Review Type Date Requested Status
Alberto Donato (community) Approve
MAAS Lander Approve
Review via email: mp+446625@code.launchpad.net

Commit message

fix: use original Host value when proxy_set_header

Resolves LP:2022926

Description of the change

In regiond we do have proxy_set_header X-Forwarded-Host $http_host; which is used by Django stuff to build absolute URL

$http_host that we use to fill it basically takes original Host header information
http://nginx.org/en/docs/http/ngx_http_proxy_module.html#var_proxy_host

So why this fix is needed:
Because if in rackd config we set Host header to $host, we are losing port information. That leads to regiond having Host header without port, leading to $http_host not having port and breaking metadata_url

To post a comment you must log in.
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b rackd-nginx-conf lp:~troyanov/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: a4c11bd4133dbfe0356e45bf1c17b99f2b8bf5cc

review: Approve
Revision history for this message
Alberto Donato (ack) wrote :

+1

review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/provisioningserver/templates/http/rackd.nginx.conf.template b/src/provisioningserver/templates/http/rackd.nginx.conf.template
2index f73a7be..8ec9ae0 100644
3--- a/src/provisioningserver/templates/http/rackd.nginx.conf.template
4+++ b/src/provisioningserver/templates/http/rackd.nginx.conf.template
5@@ -12,9 +12,9 @@ server {
6
7 {{if upstream_http}}
8 location /MAAS/ {
9- proxy_set_header Host $host;
10+ proxy_set_header Host $http_host;
11 proxy_set_header X-Real-IP $remote_addr;
12- proxy_set_header X-Forwarded-Host $host:$server_port;
13+ proxy_set_header X-Forwarded-Host $http_host;
14 proxy_set_header X-Forwarded-Server $host;
15 proxy_set_header X-Forwarded-Proto $scheme;
16 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

Subscribers

People subscribed via source and target branches