O
O
orbit0702019-05-29 16:34:51
Nginx
orbit070, 2019-05-29 16:34:51

How to link django rest framework + nginx + gunicorn?

I want to raise a simple api.
Installed DRF, added a test method to views -> "python manage.py runserver" -> API request from the same machine - it works.
Now I want to make it possible to pull this api not only from the local machine.
I saw somewhere an example with "python manage.py runserver 0.0.0.0:8000" - I tried it, I make a request from the outside - it works (although I don't quite understand why), but oh well - in any case, this is hardly the way that needed.
As far as I understand, you need to use nginx and gunicorn (or equivalents) as in the case with regular sites. Can you help with how the nginx file should look at least roughly? I can't google any guide on how to set up nginx and django rest framework. With regular djnago, there are a lot of examples, but drf is not.

server {
    listen 8000;
    server_name localhost;

    location /getHello/ {
        proxy_pass http://127.0.0.1:8000/getHello/;
     }
}

but this gives a syntax error and nginx does not start.
Please tell me at least something, maybe someone has some examples. Thanks

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question