Answer the question
In order to leave comments, you need to log in
How to properly use postman for django + ngixn?
I use a bunch of django + django rest framework + nginx with a virtual environment. I set up nginx like this https://habr.com/en/post/226419/.
The problem is that if you use the standard server (with the ./manage.py runserver command
), all urls and requests work correctly in postman. When you run uWSGI (uwsgi --ini rest_api_uwsgi.ini), everything works correctly only in the browser, but in postman all 404 urls. There are no messages in the console that requests were sent, there are no errors in the logs either. At the same time, the same requests are perfectly processed in the browser and you can see in the console what was sent. Has anyone experienced this?
Just in case, here is the config
# mysite_nginx.conf
upstream django_rest {
server unix:///public_html/rest_api/rest_api.sock; # взаимодействие с uwsgi через Unix-сокет
# server 127.0.0.1:8001; # взаимодействие с uwsgi через веб-порт
}
# конфигурация веб-сервера
server {
# порт, который будет слушать веб-сервер в ожидании запросов от пользователй
listen 8000;
# доменное имя
server_name localhost; # замените на собственный домен или IP адрес
charset utf-8;
# максимальный размер загружаемых на сервер данных
client_max_body_size 75M;
# обслуживание медиа файлов и статики
location /media {
alias /public_html/rest_api/media; # расположение медиафайлов (при необходимости измените)
}
location /static {
alias /public_html/rest_api/static; # расположение статики (при необходимости измените)
}
# Остальные запросы перенаправляются в Django приложение
location / {
uwsgi_pass django_rest;
include /public_html/rest_api/uwsgi_params;
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question