NGINX +带Rails的乘客+ Wordpress固定链接

问题描述 投票:0回答:1

我尽力了。我来这已经一个星期了。我已经尝试过通过Google,SO等找到的所有可能的解决方案。

环境如下:

我有https://website.comhttps://website.com/blog上的博客

根路径指向一个由乘客托管的Rails应用,而博客子目录则通过php-fpm指向一个Wordpress应用

[我的nginx配置一切正常,但是当我尝试将永久链接结构更改为“ Plain”以外的任何其他内容时,我会从Rails应用程序获取404页面,好像未使用位置块。我尝试在调试模式下查看错误日志,但确实看到它尝试try_files,但最终在Rails 404页面失败。

可能值得注意的是,整个站点都在Cloudflare后面。不知道这是否有可能,尽管我对此表示怀疑。

如果我能提供其他有用的信息,请告诉我!

这是我正在使用的几乎可以正常工作的nginx配置:

server {
    listen 80 default_server;
    server_name IP_ADDRESS;

    passenger_enabled on;
    passenger_app_env production;
    passenger_ruby /home/ubuntu/.rbenv/shims/ruby;

    root /web/rails/public;

    client_max_body_size 20M;

    location ^~ /blog {
                passenger_enabled off;

                alias /web/blog;
                index index.php index.htm index.html;

                # Tried the commented line below, but then nothing works.
                # try_files $uri $uri/ /blog/index.php?$args;
                # The line below works, but peramlinks don't.
                try_files $uri $uri/ /blog/index.php?q=$uri&$args;

                location ~ \.php$ {
                        include fastcgi_params;
                        fastcgi_pass unix:/run/php/php7.3-fpm.sock;

                        # Tried the commented line below, but then nothing works
                        # fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                        # The line below works, but peramlinks don't.
                        fastcgi_param SCRIPT_FILENAME $request_filename;
                }
        }
}
wordpress nginx permalinks nginx-config
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.