1
votes

To enable https, I set AWS load balancer in front of my ec2 instance. I can access Django Rest api services and admin on ec2 through Public IP. But when I try to get api response through load balancer DNS name or correspondingly domain name, e.g., example.com, I can see the welcome page of nginx. If I type example.com/api, it shows nginx not found. I have stuck for a long time, and don't know if there is something that I misunderstood. My nginx configuartion is as followed.

server {
    listen 80;
    server_name server_domain_or_IP;
    enter code here
    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
        root /home/sammy/myproject;
    }

    location / {
        include proxy_params;
        proxy_pass http://unix:/home/sammy/myproject/myproject.sock;
    }
}
1
try to change location / to location ^~ /api - Amit Baranes
Still not found. I need location to be / because there are some endpoints like auth - Li Zhaoyang
x.xx.xxx.xxx/api/xxxx return correct json object . example.com/api/xxxx return nginx not found - Li Zhaoyang

1 Answers

1
votes

It turns out that server_name needs to be domain name which is assigned to load balancer