【问题标题】:i add a ssl cer and redirect http to https but now all url are 404我添加了一个 ssl cer 并将 http 重定向到 https 但现在所有 url 都是 404
【发布时间】:2019-03-25 17:35:45
【问题描述】:

这是我的项目的 nginx conf 请告诉我为什么它不起作用

upstream django {
    server 127.0.0.1:8037;
}
server {
server_name                        ;
listen        :80;
return 301 https://www.                 $request_uri;
}
server {
   listen 443 ssl;

ssl_certificate /etc/nginx/ssl.crt/server.crt;
ssl_certificate_key /etc/nginx/ssl.key/server.key;

server_name                               ;

charset   utf-8;
server_tokens       off;
access_log /etc/nginx/log/access.log;

error_log /etc/nginx/log/error.log;

location /static/ {
    alias   /home/app/public_html/Vishka/env/repo/project/Vishka/static/;
}


location / {
        include uwsgi_params;
        uwsgi_pass django;
}
}

在 uwsgi 日志中没有请求 我所有的请求都会丢失 enter image description here

【问题讨论】:

    标签: python django ssl nginx


    【解决方案1】:

    在方案中使用端口 80 在服务器上检查

    if ($scheme != "https") {
                    return 301 https://$host$request_uri;
            }
    

    还要确保配置具有有效的语法

    listen       80 default_server;
    listen       [::]:80 default_server;
    
    listen       443 ssl http2 default_server;
    listen       [::]:443 ssl http2 default_server;
    

    【讨论】:

      【解决方案2】:

      那是因为我的服务器设置了一个子域,我在 ssl 设置中引用了主域

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-02-08
        • 1970-01-01
        • 2020-03-06
        • 1970-01-01
        • 2018-05-05
        • 2012-01-15
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多