-
Notifications
You must be signed in to change notification settings - Fork 253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove all references to settings.BASE_PATH
#189
Remove all references to settings.BASE_PATH
#189
Conversation
@@ -156,6 +152,9 @@ EXEMPT_VIEW_PERMISSIONS = [ | |||
# 'ipam.prefix', | |||
] | |||
|
|||
# If hosting Nautobot in a subdirectory, you must set this value to match the base URL prefix configured in your HTTP server (e.g. `/nautobot`). When not set, URLs will default to being prefixed by `/`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still learning how this works. If the HTTP server is setting SCRIPT_NAME
correctly, then FORCE_SCRIPT_NAME
is not required, correct? This would only be needed if SCRIPT_NAME
is incorrect?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MOST of the application works correctly without deliberately setting FORCE_SCRIPT_NAME
, but there are a few edge cases mostly related to not being able to leverage django.urls.reverse()
consistently due to circular imports caused by having to end up loading nautobot.core.urls
where nearly every single model in the project is loaded to facilitate nautobot.core.views.HomeView
and SearchView
.
So for now, to allow for places where APISelect
widgets are being used, namely the Device.position
dynamic lookup, this is the only way to assert that we can reliably make the app receive the correct SCRIPT_NAME
. If we can refactor enough to be able to use reverse()
everywhere we need to specify URLs, we can stop hard-coding API URLs in the code and can simplify deployment even further.
Fixes: #166 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like there's also a reference to contrib
in nautobot/docs/installation/upgrading.md that probably needs to be updated as well.
|
||
If the location of SSL certificates had to be changed in `Obtain an SSL Certificate` step, then the location will need to be changed in the `apache.conf` file as well. | ||
```apache |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you will need to add apache
to the hljs_languages:
list in mkdocs.yml
for this to get highlighted appropriately, though I'd love to be wrong on this point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would also be great to add nginx
highlighting to the NGINX config earlier in this file, and enable it in the mkdocs.yml
as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tried it and it didn't seem to do anything. 🤷
Yeah I wasn't touching that doc just yet. It's still on the todo list and I figured I'd just do that then. |
This now relies on the HTTP CGI variable `SCRIPT_NAME` to be passed in upstream from the HTTP server (e.g. NGINX) paired with matching uWSGI configuration. This also refactors social auth URL to never rely upon `BASE_PATH` and instead replace hard-coding `LOGIN_URL` w/ a template condition on `settings.SOCIAL_AUTH_ENABLED`. Further, this means that the social auth URL can naturally inherit the derived base path sent from the HTTP server without having to hard-code it. - Correct references to hard-coded URLs and instead let them reverse properly - Update uwsgi settings to include optional setting for subdir hosting - The default values of `STATIC_URL` and `MEDIA_URL` are now relative URL paths to allow for them to inherit the derived base path. Under normal circumstatnces this is equivalent to them being absolute. - In the event that a HTTP server sets the base path with `SCRIPT_NAME`, (e.g. `/nautobot`) then these automatically get prefixed (e.g. `/nautobot/static/`). If a user requires custom static/media paths, they may still customize these values for their setup. - Generic view for `nautobot.core.views.HomeView` updated to `TemplateView` to help in template debugging.
- Make extras forms call api_url w/ a route name vs. URL path
This also splits core API URLs into `nautobot.core.api.urls` and `include` those URLs in `nautobot.core.urls` to reduce the amount of circular dependencies going on in `nautobot.core`
- Update production configs to remind use of `FORCE_SCRIPT_NAME` to match that of HTTP config - Update config init template to include `FORCE_SCRIPT_NAME` - Fix URL join in `widgets.py` - Added a basic unit test for `FORCE_SCRIPT_NAME`
Update docs to reference subdir prefix using trailing slash for consistency, since this is what Django emits it as.
- Fold `apache.conf` into install docs for http-server - Update `FORCE_SCRIPT_NAME` test to use `try...finally`
03e16cf
to
f0127d1
Compare
Just rebased against upstream. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixes: #147
This now relies on the HTTP CGI environment variable
SCRIPT_NAME
to be passed in upstream from the HTTP server (e.g. NGINX) paired with matching uWSGI configuration and thatFORCE_SCRIPT_NAME
be set innautobot_config.py
to match the configured path.This also refactors the social auth URL to never rely upon
BASE_PATH
and instead replace hard-codingLOGIN_URL
w/ a template condition onsettings.SOCIAL_AUTH_ENABLED
. Further, this means that the social auth URL can naturally inherit the derived base path sent from the HTTP server without having to hard-code it.The default values of
STATIC_URL
andMEDIA_URL
are now relative URL paths to allow for them to inherit the derived base path. Under normal circumstances this is equivalent to them being absolute.In the event that a HTTP server sets the base path with the HTTP environment variable
SCRIPT_NAME
, (e.g./nautobot
) then ALL URLs automatically get prefixed (e.g./nautobot/static/
). If a user requires custom static/media paths, they may still customize these values for their setup.Other updates:
nautobot.core.api.urls
andinclude
those URLs innautobot.core.urls
to reduce the amount of circular dependencies going on innautobot.core
LOGIN_URL
andLOGIN_REDIRECT_URL
are now using URL route names and not hard-coded pathsuwsgi_param
) config directives, and to include optional setting for subdir hostingsocket
(uWSGI protocol) vs.http-socket
when behind NGINX anduwsgi_param
to configure NGINXnautobot.core.views.HomeView
updated toTemplateView
to help in template debugging.social_django
so that various auth backend variables can be used in templates.social-auth-app-django
as a hard dependency to simplify dynamism in the SSO login URL.FORCE_SCRIPT_NAME
to match that of HTTP configFORCE_SCRIPT_NAME
FORCE_SCRIPT_NAME
contrib/
directory once and for all and all references tocontrib/
(except in upgrading doc, which will come later)