Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django Rest framework swagger base url

I have successfully running my rest framework swagger on localhost.. These was my rest framework swagger localhost screenshoot. It has run successfully.

enter image description here

Now i want to deploy it on server testing. These is the screenshot result of my testing deployment. enter image description here

As you can see the base path changed and served from localhost, the schemes read the right configuration which is https schemes, and the application run in the right domain which is api.executivemafia.com, so that's not problem. The problem come when I want to try the API. The server point is localhost. So it's make my endpoint request become 'https://127.0.0.1:8000/instagram/hello".

My questions are:

  1. Why the rest framework swagger still read localhost although my application already served in https://api.executivemafia.com/docs/? Fyi, I set the proxy pass nginx to locahost:8000 because my gunicorn run on localhost:8000.

  2. Can the base url rest framework swagger testing server using my testing server domain end point ? If it's able to, how to do it?

Any help and reference will be appreciated.

Thank you Guys!!

Regards,

Meikelwis Wijaya

like image 382
Meikelwis Wijaya Avatar asked Sep 15 '25 03:09

Meikelwis Wijaya


1 Answers

Set the following inside the nginx configuration file:

server{
    ........
    location /{
       proxy_pass http://yourhostname:port;
       proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
       proxy_set_header Host $http_host;
       proxy_set_header X-Forwarded-Host $server_name;
       proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header X-Forwarded-Proto $scheme;
       proxy_redirect off;
    }
}

it worked for me !!

like image 164
Ripundeep Gill Avatar answered Sep 17 '25 18:09

Ripundeep Gill