I use an apache container which acts as a loadbalancer and redirects the flow to 2 apache wsgi. I use django-rest-framework on the 2 apaches.
I have a problem to get the files. Indeed, the api returns me:
{
avatar: http://127.0.0.1:8000/media/avatars/2.jpg
}
Instead of http://127.0.0.1:8000/
, I want the api to return https://api.myservice/
How to force the url ?
CodePudding user response:
Looks similar to this question. The answer there mentions:
Django's reverse uses request's domain to build absolute URL.
So make sure to pass the Host header in your proxy. From the comments on the linked answer, ProxyPreserveHost should do the job for Apache.