我正在运行Django应用,并使用Gunicorn和Nginx将其部署在服务器上。它在Http上运行了一年。现在,我使用“ letsencrypt”将其更改为Https。这是我的nginx配置。
server {
server_name my_project.com;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /home/ubuntu/my_project/my_project/;
}
location / {
proxy_pass_header Server;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_connect_timeout 10;
proxy_read_timeout 10;
proxy_pass http://localhost:8000;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/my_project.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/my_project.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = my_project.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
server_name my_project.com;
return 404; # managed by Certbot
}
当我在浏览器中打开项目页面时,此配置工作正常,即将我重定向到https页面。但是我的Api呼叫均无效。我收到未找到该方法的错误。请指导我如何解决此问题?