Add more safe META constants to expose those to custom scripts #8507

Closed
opened 2025-12-29 20:37:34 +01:00 by adam · 0 comments
Owner

Originally created by @carsten-AEI on GitHub (Aug 24, 2023).

Originally assigned to: @abhi1693 on GitHub.

NetBox version

v3.5.8

Feature type

Change to existing functionality

Proposed functionality

Add HTTP_X_FORWARDED_HOST, HTTP_X_FORWARDED_PROTO and HTTP_X_REAL_IP to HTTP_REQUEST_META_SAFE_COPY allow custom scripts access to.these.

Use case

I was running a simple custom script but needed to rely on HTTP_REFERER to infer how the script was being called to generate valid links in the response of the script. @candlerb meant in https://github.com/netbox-community/netbox/discussions/13527 that he would not recommend it.

Long story short, after some debugging it seems best to add HTTP_X_FORWARDED_HOST, HTTP_X_FORWARDED_PROTO and HTTP_X_REAL_IP to HTTP_REQUEST_META_SAFE_COPY to allow custom scripts to use those as well.

Without this, HTTP_HOST would only show the address gunicorn was listening to.

Database changes

./.

External dependencies

./.

Originally created by @carsten-AEI on GitHub (Aug 24, 2023). Originally assigned to: @abhi1693 on GitHub. ### NetBox version v3.5.8 ### Feature type Change to existing functionality ### Proposed functionality Add `HTTP_X_FORWARDED_HOST`, `HTTP_X_FORWARDED_PROTO` and `HTTP_X_REAL_IP` to [`HTTP_REQUEST_META_SAFE_COPY`](https://github.com/netbox-community/netbox/blob/8f5005efd5f8f8df60ea5e33a1d79210a114a227/netbox/utilities/constants.py#L38) allow custom scripts access to.these. ### Use case I was running a simple custom script but needed to rely on HTTP_REFERER to infer how the script was being called to generate valid links in the response of the script. @candlerb meant in https://github.com/netbox-community/netbox/discussions/13527 that he would not recommend it. Long story short, after some debugging it seems best to add `HTTP_X_FORWARDED_HOST`, `HTTP_X_FORWARDED_PROTO` and `HTTP_X_REAL_IP` to [`HTTP_REQUEST_META_SAFE_COPY`](https://github.com/netbox-community/netbox/blob/8f5005efd5f8f8df60ea5e33a1d79210a114a227/netbox/utilities/constants.py#L38) to allow custom scripts to use those as well. Without this, `HTTP_HOST` would only show the address gunicorn was listening to. ### Database changes ./. ### External dependencies ./.
adam added the status: acceptedtype: feature labels 2025-12-29 20:37:34 +01:00
adam closed this issue 2025-12-29 20:37:34 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#8507