Update the nginx documentation #3227

Closed
opened 2025-12-29 18:26:53 +01:00 by adam · 1 comment
Owner

Originally created by @smutel on GitHub (Jan 27, 2020).

Change Type

[ ] Addition
[X] Correction
[ ] Deprecation
[ ] Cleanup (formatting, typos, etc.)

Proposed Changes

In the nginx configuration, the line below:

proxy_set_header X-Forwarded-Host $server_name;

should be replaced by this line to take account of port used to reach netbox:

proxy_set_header X-Forwarded-Host $http_host;

In the previous configuration, nginx assume that you are calling it on port 80. So the next field on the JSON response when you call the API only contains port 80.

Originally created by @smutel on GitHub (Jan 27, 2020). <!-- Please indicate the nature of the change by placing an X in one of the boxes below. --> ### Change Type [ ] Addition [X] Correction [ ] Deprecation [ ] Cleanup (formatting, typos, etc.) <!-- Describe the proposed change(s). --> ### Proposed Changes In the nginx configuration, the line below: ``` proxy_set_header X-Forwarded-Host $server_name; ``` should be replaced by this line to take account of port used to reach netbox: ``` proxy_set_header X-Forwarded-Host $http_host; ``` In the previous configuration, nginx assume that you are calling it on port 80. So the next field on the JSON response when you call the API only contains port 80.
adam added the status: acceptedtype: documentation labels 2025-12-29 18:26:53 +01:00
adam closed this issue 2025-12-29 18:26:53 +01:00
Author
Owner

@jeremystretch commented on GitHub (Jan 29, 2020):

LGTM, but I want to ensure including the port number won't break anything. Per Django's documentation this should be fine.

Testing confirmed that when listening on a default HTTP port (i.e. 80), the port number is omitted from the URLs returned in API responses when $http_host is used, so that should not be an issue.

@jeremystretch commented on GitHub (Jan 29, 2020): LGTM, but I want to ensure including the port number won't break anything. Per [Django's documentation](https://docs.djangoproject.com/en/2.2/ref/settings/#use-x-forwarded-host) this should be fine. Testing confirmed that when listening on a default HTTP port (i.e. 80), the port number is omitted from the URLs returned in API responses when `$http_host` is used, so that should not be an issue.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#3227