首页 > 解决方案 > SilverStripe 4 / NGINX 在尝试编辑草稿页面时重定向到 404

问题描述

我得到了一个 NGNIX 服务器,它以前只安装了 Ubuntu 18.04 和 NGNIX,用于呈现静态 html 站点。

我已经安装了 PHP、MySqli 等并配置了站点可用文件以使网站启动并运行。将数据库从开发站点导入实时站点后,除了一个错误之外,该网站的工作正常如预期。

如果我在“拆分模式”或“预览模式”下单击草稿页面,我会被重定向到管理员中的“未找到页面”。如果我切换到“编辑模式”,一切都会很好。一旦我发布了草稿页面,我就可以在“拆分模式”或“预览模式”中完美地查看它。

我想知道这是否与我的 NGNIX 配置有关。我使用以下链接配置了我的站点可用/默认文件: https ://www.nginx.com/resources/wiki/start/topics/recipes/silverstripe/#recipe

这是我的 ngnix 站点可用配置文件

    server {
            include mime.types;
            default_type  application/octet-stream;
            #listen 80 default_server;
            #listen [::]:80 default_server;
    
            listen 443 ssl default_server;
            listen [::]:443 ssl default_server;
    
            ssl        on;
            ssl_certificate         /etc/ssl/certs/certificate.pem;
            ssl_certificate_key     /etc/ssl/private/key.key;
    
            root ****************
    
            # Add index.php to the list if you are using PHP
            index index.php index.html index.htm index.nginx-debian.html;
    
            server_name ****************;
    
            location / {
                    # First attempt to serve request as file, then
                    # as directory, then fall back to displaying a 404.
                    try_files $uri /index.php?query_string;
            }
            error_page 404 /assets/error-404.html;
            error_page 500 /assets/error-500.html;
    
            # see caveats
            error_page 502 /assets/error-500.html;
            error_page 503 /assets/error-500.html;
    
            location ^~ /assets/ {
                    sendfile on;
                    try_files $uri =404;
            }
    
            location /index.php {
                    fastcgi_buffer_size 32k;
                    fastcgi_busy_buffers_size 64k;
                    fastcgi_buffers 4 32k;
                    fastcgi_keep_conn on;
                    fastcgi_pass   127.0.0.1:9000;
                    fastcgi_index  index.php;
                    fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
                    include        fastcgi_params;
            }
    
            # pass PHP scripts to FastCGI server
            #
            location ~ \.php$ {
                    include snippets/fastcgi-php.conf;
    
                    # With php-fpm (or other unix sockets):
                    fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
                    # With php-cgi (or other tcp sockets):
            #       fastcgi_pass 127.0.0.1:9000;
            }
    
            # deny access to .htaccess files, if Apache's document root
            # concurs with nginx's one
            #
            location ~ /\.ht {
                    deny all;
            }
    }

当我导航到 /install.php 时,我没有收到任何警告或错误。

关于可能导致这种情况的任何线索?如果您需要更多信息,请告诉我。

标签: phpnginxsilverstripesilverstripe-4

解决方案


推荐阅读