gpt4 book ai didi

Django + Nginx 配置(获取 "Welcome to nginx!")

转载 作者:行者123 更新时间:2023-12-02 17:00:55 25 4
gpt4 key购买 nike

我在 Ubuntu 上安装了 Django + Nginx + Gunicorn。使用 Letsencrypt 生成的证书。

/etc/nginx/sites-available/myproject 我有:

server {
server_name myproject.com www.myproject.com;
listen 80;
return 301 https://myproject.com$request_uri;
}

server {
server_name myproject.com www.myproject.com;

listen 443;

ssl on;
ssl_certificate /etc/letsencrypt/live/myproject.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/myproject.com/privkey.pem;

client_max_body_size 1G;

root /home/myname/myproject;

location / {
include proxy_params;
proxy_pass https://unix:/home/myname/myproject/myproject.sock;
}
}

/etc/nginx/sites-available/default 中,除了注释行,我有:

server {
listen 80 default_server;
listen [::]:80 default_server;

root /var/www/html;

index index.html index.htm index.nginx-debian.html;

server_name _;

location / {
try_files $uri $uri/ =404;
}
}

/etc/nginx/sites-enabled 我有 default 和 myproject。

当我转到 https://myproject.com 时,我看到“欢迎使用 nginx!”,但我希望看到 Django 的默认页面。它重定向到“欢迎使用 nginx!”,我做错了什么?

最佳答案

只需禁用默认配置:

rm /etc/nginx/sites-enabled/default
systemctl reload nginx

关于Django + Nginx 配置(获取 "Welcome to nginx!"),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54244753/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com