Use Nginx’s Django REST framework absolute URL always returns 127.0.0.1

I use gunicorn/django (using django-rest-framework) behind nginx to run the application, and when using hyperlinkedmodelserializer, I have a little problem with the url return using the rest of the framework. They Always return something like http://127.0.0.1/ instead of my hostname.

Can you help?

It’s okay, I found that I forgot

proxy_set_header Host $host:$server_port;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

In my nginx configuration. It works fine now.

I use gunicorn/django (using django-rest-framework) behind nginx to run the application, and when using hyperlinkedmodelserializer, I have a little problem with the url return using the rest of the framework. They always return Similar to http://127.0.0.1/ instead of my hostname.

Can you help?

It’s okay, I found out I forgot

proxy_set_header Host $host:$server_port; 
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

In my nginx configuration. It works fine now.

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 4666 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.