Code

Opened 22 months ago

Closed 20 months ago

Last modified 20 months ago

#18987 closed Uncategorized (invalid)

Django contrib admin redirection error on actions

Reported by: audirs2 [at] gmail.com Owned by: nobody
Component: contrib.admin Version: 1.4
Severity: Normal Keywords: redirect remote_auth_backend nginx
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by aaugustin)

When user remote user authentication backend and accessing django application via Nginx proxy on subdomain behind this proxy the admin interface does not redirect from admin actions correctly.

Settings below are applied:

FORCE_SCRIPT_NAME=''
APPEND_SLASH=False

Server is running mod_wsgi

accessing works ok.

https://djangoapp.domain.com/admin/

When using an admin action to add/delete etc redirects badly.

E.g. on page url below you update some config and click add as the admin action, the underlying code carries out the action.

https://djangoapp.domain.com/admin/appname/add/

However when django redirects back to the apps list of objects it redirects badly to a url shown in the form below

https://djangoapp.domain.com/admin/appname/add/.domain.com/admin/appname/add/

It appears that the url resolution is using the domain with subdomain stripped and then as this is not the same full url it appends this url to the current one

Attachments (0)

Change History (3)

comment:1 follow-up: Changed 22 months ago by audirs2 [at] gmail.com

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Appears to be caused by TemplateResponse handling

comment:2 in reply to: ↑ 1 Changed 22 months ago by audirs2 [at] gmail.com

Upon further investigation it appears to be caused by the HTTP module django/http/init.py in build_absolute_uri

Where the location full path is returned incorrectly by urlparse in the form .domain.com/admin/appname/add/ and self.path is used by get_full_path both have the same issue.

Suggest changing the behaviour of build abosolute url to check for this behaviour as their should always be a leading slash on the url so could check if that is the case and split the url if required. e.g.

   self.path.split('/',1)[1] 

to obtain the actual path?

comment:3 Changed 20 months ago by aaugustin

  • Description modified (diff)
  • Resolution set to invalid
  • Status changed from new to closed

(Fixed formatting -- please use preview.)

If I understand correctly you have two layers: a frontend (nginx) that dispatches to a backend (apache+mod_wsgi). This is a very common setup and you don't need FORCE_SCRIPT_NAME to make it work properly.

I don't understand your second comment: I don't see anything related to urlparse in build_absolute_uri.

Generally speaking, the information you've provided is rather sparse, and we have evidence that the admin works for thousands of developers using the same setup as you.

This looks like a misconfiguration. I suggest using the support channels.

Last edited 20 months ago by aaugustin (previous) (diff)

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.