Hi James. 
Thanks for your attention and the stackoverflow reference

I try setup the headers in my nginx configuration file but I don't get 
success

My /etc/nginx/sites-enabled/myproject file I had so:

server {
    server_name yourdomainorip.com;
    access_log off;
    location / {
            proxy_pass http://127.0.0.1:8000;
            proxy_set_header X-Forwarded-Host $server_name
            proxy_set_header X-Real-IP $remote_addr;
            add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM 
NAV"';
    }
}


According to the 
reference 
http://stackoverflow.com/questions/19669376/django-rest-framework-absolute-urls-with-nginx-always-return-127-0-0-1
 
my /etc/nginx/sites-enabled/myproject file I stayed so:

server {
    server_name yourdomainorip.com;
    access_log off;
    location / {
            proxy_pass http://127.0.0.1:8000;
            proxy_set_header Host $host;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM 
NAV"';
    }
}

But, the result was a bad request (400) how to you can see here 
http://ec2-52-90-253-22.compute-1.amazonaws.com/ 

What is the order in which I should setup the headers?
Thanks
On Tuesday, February 23, 2016 at 4:51:16 PM UTC-5, James Schneider wrote:
>
>
>
> On Tue, Feb 23, 2016 at 6:03 AM, Bernardo Garcia <boti...@gmail.com 
> <javascript:>> wrote:
>
>> Hi everyone Djangonauts
>> :)
>>
>> Currently I am exposing a Django application (for the momento is just 
>> thier users schema) with Django Rest Framework and happen that each 
>> serialized model, in the url attribute, I have is the localhost machine 
>> address development and don't take the hostname of my production server 
>> machine which is located in amazon like as EC2 instance
>>
>>
>> In this picture can detailed it.
>>
>
> Nginx is proxying the end-users' request to http://127.0.0.1:8000, which 
> is where Gunicorn is running. Gunicorn has no idea that there is a proxy in 
> front of it, so it assumes that the request is being sent by the server 
> itself, to the server itself. Gunicorn then passes along the Host header to 
> Django/DRF, which in turn uses it to generate the URL's that you are 
> getting.
>
> You need to tell Nginx to send the correct headers to indicate to Gunicorn 
> that the connection is being proxied, and the correct address to use. See 
> this SO: 
>
>
> http://stackoverflow.com/questions/19669376/django-rest-framework-absolute-urls-with-nginx-always-return-127-0-0-1
>
> -James
>

-- 
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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/740b268b-df39-4b2d-bd81-33217a154de0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to