Nginx 与 SSL - 刷新页面显示 404

Nginx 与 SSL - 刷新页面显示 404

我最近为我的解析服务器安装了支持 SSL 的 Nginx。

当我输入基本 https url 时,工作正常,但当我尝试刷新页面时,出现 404 错误。

可能是 Ngix 配置错误。

这是我的 nginx.conf

events {
   worker_connections 1024;
}
http{
        server_tokens off;
        charset utf-8;

        # HTTP - redirect all requests to HTTPS
        server {
                listen 80;
                listen [::]:80;
                return 301 https://$host$request_uri;
        }

        # HTTPS - serve HTML from /usr/share/nginx/html, proxy requests to /parse/
        # through to Parse Server
        server {
                        listen 443 ssl http2;

                        server_name my-app-api.ch ;

                        root /usr/share/nginx/html;
                        index index.html index.htm;

                        # Use certificate and key provided by Let's Encrypt:
                        ssl_certificate /etc/letsencrypt/live/my-app-api.ch/fullchain.pem;
                        ssl_certificate_key /etc/letsencrypt/live/my-app-api.ch/privkey.pem;

                        # Pass requests to Parse Server instance at localhost:1337
                        location / {
                                        # prevents 502 bad gateway error
                                        proxy_buffers 8 32k;
                                        proxy_buffer_size 64k;

                                        proxy_set_header X-Real-IP $remote_addr;
                                        proxy_set_header Access-Control-Allow-Origin '*';
                                        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                                        proxy_set_header X-NginX-Proxy true;
                                        proxy_pass http://172.20.0.5:1337/;
                                        proxy_ssl_session_reuse off;
                                        proxy_set_header Host $http_host;
                                        proxy_redirect off;

                                        # enables WS support
                                        proxy_http_version 1.1;
                                        proxy_set_header Upgrade $http_upgrade;
                                        proxy_set_header Connection "upgrade";

                                        proxy_read_timeout 999999999;
        #                                       try_files $uri $uri/ =404;
                        }
                        location ~ /.well-known/acme-challenge/ {
                                root /var/www/certbot;
                        }

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

提前感谢任何想法

相关内容