yaa
On Saturday, 23 October 2021 at 04:44:10 UTC-7 [email protected] wrote:

> I don't know but I'm interested in that
>
> 在2021年10月20日星期三 UTC+8 上午3:37:04<[email protected]> 写道:
>
>>
>> I am running a small django app with django admin.
>> In fact, I only use django admin to edit a few models.
>>
>> It works fine in local and behind a simple proxy reverse, but now I have 
>> this kind a rewrite that changes the path: (it's a nginx ingress rewrite 
>> rule for Kubernetes)
>>
>> path: /diagnosis-admin(/|$)(.*) => $2
>>
>> Wich means, urls such as mydomain.com/diagnosis-admin redirect to 
>> localhost/ (mind the path change.
>>
>> When I try to access the admin at mydomain.com/diagnosis-admin/admin, 
>> django tries to redirect to mydomain.com/admin/, which leads nowhere 
>> because it falls on the proxy:
>>
>>
>>    1. Request URL: 
>>       https://mydomain.com/diagnosis-admin/admin
>>       2. Request Method: 
>>       GET
>>       3. Status Code: 
>>       301 
>>       4. Remote Address: 
>>       138.21.17.33:3128
>>       5. Referrer Policy: 
>>       strict-origin-when-cross-origin
>>       1. Response Headers
>>       1. content-length: 
>>       0
>>       2. content-type: 
>>       text/html; charset=utf-8
>>       3. date: 
>>       Tue, 19 Oct 2021 15:11:42 GMT
>>       4. location: 
>>       /admin/
>>       5. script_name: 
>>       /diagnosis-admin
>>       6. strict-transport-security: 
>>       max-age=15724800; includeSubDomains
>>       7. x-content-type-options: 
>>       nosniff
>>    
>>
>> I had this problems with other applicative frameworks but could solve it 
>> since they can interpret the FORWARDED_HOST, FORWARDED_PORT and 
>> FORWARDED_PATH headers provided by the proxy.
>>
>> Searching the internets gave me tons of solutions for reverse proxy with 
>> simple rewrite rules with no path alterations, but here I am stuck 
>>
>> I have no idea how to solve this withing django. Any help will be much 
>> appreciated
>>
>>
>> Additionnal information:
>> I run django with "python manage.py runserver 0.0.0.0:8000" on a docker 
>> container (running through GKE)
>>
>> Everything is pretty standard, I ran the basic django project scafolding, 
>> setup the database, auto migrated the models and that's about it. I can 
>> provide additionnal files if needed
>>
>>
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6dd77ed7-8645-4306-ab0a-01279eb3cb96n%40googlegroups.com.

Reply via email to