Add USE_X_FORWARDED_PORT to settings #6855

Closed
opened 2025-12-29 19:46:05 +01:00 by adam · 4 comments
Owner

Originally created by @sol1-matt on GitHub (Aug 23, 2022).

NetBox version

v3.3.0

Feature type

New functionality

Proposed functionality

Add new setting USE_X_FORWARDED_PORT for SAML auth through a transparent proxy.

Use case

Enable SAML to work with Netbox through transparent proxy.

When django is running through a transparent proxy an error can occur because the listening port for the django app is different from the SAML return url.

Authentication failed: SAML login failed: ['invalid_response'] 
(The response was received at https://netbox.example.com:8000/social/complete/saml/ instead of https://netbox.example.com/social/complete/saml/)

The solution for any django app is to add a X-Forwarded-Port header to the proxy and set USE_X_FORWARDED_PORT = True in the django application.

An example of the problem and solution can be found here.

Database changes

none

External dependencies

none

Originally created by @sol1-matt on GitHub (Aug 23, 2022). ### NetBox version v3.3.0 ### Feature type New functionality ### Proposed functionality Add new setting `USE_X_FORWARDED_PORT` for SAML auth through a transparent proxy. ### Use case Enable SAML to work with Netbox through transparent proxy. When django is running through a transparent proxy an error can occur because the listening port for the django app is different from the SAML return url. ``` Authentication failed: SAML login failed: ['invalid_response'] (The response was received at https://netbox.example.com:8000/social/complete/saml/ instead of https://netbox.example.com/social/complete/saml/) ``` The solution for any django app is to add a `X-Forwarded-Port` header to the proxy and set `USE_X_FORWARDED_PORT = True` in the django application. An example of the problem and solution can be found [here](https://github.com/onelogin/python3-saml/issues/83). ### Database changes none ### External dependencies none
adam added the type: featurestatus: needs ownerpending closure labels 2025-12-29 19:46:05 +01:00
adam closed this issue 2025-12-29 19:46:06 +01:00
Author
Owner

@sol1-matt commented on GitHub (Aug 23, 2022):

The specific auth provider this was needed for is Jumpcloud with a Nginx proxy in front of uwsgi on port 8000. The proxy is on the Netbox server and the domain for Nginx and uwsgi is the same.

There is an additional setting USE_X_FORWARDED_HOST which I haven't tested but probably does what it says on the box.

@sol1-matt commented on GitHub (Aug 23, 2022): The specific auth provider this was needed for is Jumpcloud with a Nginx proxy in front of uwsgi on port 8000. The proxy is on the Netbox server and the domain for Nginx and uwsgi is the same. There is an additional setting `USE_X_FORWARDED_HOST` which I haven't tested but probably does what it says on the box.
Author
Owner

@sol1-matt commented on GitHub (Aug 23, 2022):

tested solution here 26ee79cdf9
conjunction with USE_X_FORWARDED_HOST = True in configuration.py

@sol1-matt commented on GitHub (Aug 23, 2022): tested solution here https://github.com/sol1-matt/netbox/commit/26ee79cdf90f6c25258bece3232ff67a8502231b conjunction with `USE_X_FORWARDED_HOST = True` in `configuration.py`
Author
Owner

@github-actions[bot] commented on GitHub (Nov 16, 2022):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Do not attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our contributing guide.

@github-actions[bot] commented on GitHub (Nov 16, 2022): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. **Do not** attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our [contributing guide](https://github.com/netbox-community/netbox/blob/develop/CONTRIBUTING.md).
Author
Owner

@github-actions[bot] commented on GitHub (Dec 17, 2022):

This issue has been automatically closed due to lack of activity. In an effort to reduce noise, please do not comment any further. Note that the core maintainers may elect to reopen this issue at a later date if deemed necessary.

@github-actions[bot] commented on GitHub (Dec 17, 2022): This issue has been automatically closed due to lack of activity. In an effort to reduce noise, please do not comment any further. Note that the core maintainers may elect to reopen this issue at a later date if deemed necessary.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#6855