[Bug] Ports not included in API URLs #988

Closed
opened 2025-12-29 16:27:36 +01:00 by adam · 2 comments
Owner

Originally created by @DerekTBrown on GitHub (May 24, 2017).

Issue type:

Bug

Python version: Python 2.7
NetBox version: ee9b4f5d687e (v2.0-beta1)
(Running on Docker NetBox Build)

I am running NetBox on an irregular port (8001). When I access the API endpoint (/api/), the port isn't included in the URLs which are generated (ie localhost/api/ipam/vrfs), which is an invalid link. The port should be present in these links.

Originally created by @DerekTBrown on GitHub (May 24, 2017). ### Issue type: Bug **Python version:** Python 2.7 **NetBox version:** ee9b4f5d687e (v2.0-beta1) (Running on Docker NetBox Build) I am running NetBox on an irregular port (8001). When I access the API endpoint (/api/), the port isn't included in the URLs which are generated (ie `localhost/api/ipam/vrfs`), which is an invalid link. The port should be present in these links.
adam closed this issue 2025-12-29 16:27:36 +01:00
Author
Owner

@jeremystretch commented on GitHub (May 24, 2017):

(Reposting my comment on #1184, which was closed due to lack of a response.)

The URLs for serialized objects are formed using Django REST Framework's HyperlinkedIdentityField, which determines the host for the URL based on the incoming request. It looks like your httpd isn't forwarding information about the port it's running on to the WSGI service behind it.

If you're using nginx, try adding the following to your location / block:

proxy_set_header Host $host:8001;

Also, please be sure to upgrade to the current release (v2.0.3).

@jeremystretch commented on GitHub (May 24, 2017): (Reposting my comment on #1184, which was closed due to lack of a response.) The URLs for serialized objects are formed using Django REST Framework's [HyperlinkedIdentityField](http://www.django-rest-framework.org/api-guide/relations/#hyperlinkedidentityfield), which determines the host for the URL based on the incoming request. It looks like your httpd isn't forwarding information about the port it's running on to the WSGI service behind it. If you're using nginx, try adding the following to your `location /` block: ``` proxy_set_header Host $host:8001; ``` Also, please be sure to upgrade to the current release (v2.0.3).
Author
Owner

@DerekTBrown commented on GitHub (May 24, 2017):

That resolved the problem! Thanks!

@DerekTBrown commented on GitHub (May 24, 2017): That resolved the problem! Thanks!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#988