Swagger UI URL issue when Netbox is published behind a reverse proxy #909

Closed
opened 2025-12-29 16:26:53 +01:00 by adam · 4 comments
Owner

Originally created by @dav3860 on GitHub (May 3, 2017).

Issue type: feature request

Python version: 2.7.5
NetBox version: 2.0b3

We publish Netbox behind a reverse proxy in HTTPS. But in the Swagger UI, all the links and actions have a protocol set to http. So it doesn't work.
It would be nice if Swagger could use relative URIs or if we could specify the exposed URL of Netbox in the config file.

Originally created by @dav3860 on GitHub (May 3, 2017). <!-- Please note: GitHub issues are to be used only for feature requests and bug reports. For installation assistance or general discussion, please join us on the mailing list: https://groups.google.com/forum/#!forum/netbox-discuss Please indicate "bug report" or "feature request" below. Be sure to search the existing set of issues (both open and closed) to see if a similar issue has already been raised. --> ### Issue type: feature request <!-- If filing a bug, please indicate the version of Python and NetBox you are running. (This is not necessary for feature requests.) --> **Python version:** 2.7.5 **NetBox version:** 2.0b3 <!-- If filing a bug, please record the exact steps taken to reproduce the bug and any errors messages that are generated. If filing a feature request, please precisely describe the data model or workflow you would like to see implemented, and provide a use case. --> We publish Netbox behind a reverse proxy in HTTPS. But in the Swagger UI, all the links and actions have a protocol set to http. So it doesn't work. It would be nice if Swagger could use relative URIs or if we could specify the exposed URL of Netbox in the config file.
adam closed this issue 2025-12-29 16:26:53 +01:00
Author
Owner

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

I also run NetBox on HTTPS but don't have this problem. Can you please share you configurations and the version of Swagger you have installed?

@jeremystretch commented on GitHub (May 3, 2017): I also run NetBox on HTTPS but don't have this problem. Can you please share you configurations and the version of Swagger you have installed?
Author
Owner

@dav3860 commented on GitHub (May 4, 2017):

Here is the version of Swagger :
django-rest-swagger (2.1.2)

My server is named "netbox" and served behind https://netbox, but :
capture

Here is my Apache configuration for this vHost :

<VirtualHost *:80>
  ServerName netbox
  Redirect permanent / https://netbox/
</VirtualHost>

<VirtualHost *:443>
  ServerName netbox
  ErrorLog logs/netbox_ssl_error_log
  TransferLog logs/netbox_ssl_access_log
  LogLevel warn
  Include /etc/httpd/includes.d/ssl_cert.conf

  Alias /static /opt/netbox/netbox/static

  <Directory /opt/netbox/netbox/static>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Require all granted
  </Directory>

  <Location /static>
    ProxyPass !
  </Location>

  ProxyPass / http://127.0.0.1:8001/
  ProxyPassReverse / http://127.0.0.1:8001/
</VirtualHost>
@dav3860 commented on GitHub (May 4, 2017): Here is the version of Swagger : `django-rest-swagger (2.1.2)` My server is named "netbox" and served behind https://netbox, but : ![capture](https://cloud.githubusercontent.com/assets/2794902/25695687/6443e4aa-30b4-11e7-886e-a293f5676483.PNG) Here is my Apache configuration for this vHost : ``` <VirtualHost *:80> ServerName netbox Redirect permanent / https://netbox/ </VirtualHost> <VirtualHost *:443> ServerName netbox ErrorLog logs/netbox_ssl_error_log TransferLog logs/netbox_ssl_access_log LogLevel warn Include /etc/httpd/includes.d/ssl_cert.conf Alias /static /opt/netbox/netbox/static <Directory /opt/netbox/netbox/static> Options Indexes FollowSymLinks MultiViews AllowOverride None Require all granted </Directory> <Location /static> ProxyPass ! </Location> ProxyPass / http://127.0.0.1:8001/ ProxyPassReverse / http://127.0.0.1:8001/ </VirtualHost> ```
Author
Owner

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

I'm not able to replicate this, but I'm using nginx as a frontend. Can you inspect the AJAX request in the browser to determine if it's being redirected?

@jeremystretch commented on GitHub (May 4, 2017): I'm not able to replicate this, but I'm using nginx as a frontend. Can you inspect the AJAX request in the browser to determine if it's being redirected?
Author
Owner

@dav3860 commented on GitHub (May 9, 2017):

I managed to fix it. I just added RequestHeader set X-Forwarded-Proto "https" to the Apache configuration and it started working.

@dav3860 commented on GitHub (May 9, 2017): I managed to fix it. I just added `RequestHeader set X-Forwarded-Proto "https"` to the Apache configuration and it started working.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#909