nginx返回404而不是将请求转发给Rails(nginx returns 404 instead of farwarding the request to Rails)

编程入门 行业动态 更新时间:2024-10-16 18:29:41
nginx返回404而不是将请求转发给Rails(nginx returns 404 instead of farwarding the request to Rails)

我正在使用nginx和Pushion乘客。 如果我请求这个资源https://www.chinadialogue.net/article/show/single/ch/3982-Moving-past-Mexico我从nginx获得404而不是命中Rails。 我检查了日志。 Rails正在使用SLUG,因此3982之后的任何内容(文章ID)仍然返回3982,请尝试:

https://www.chinadialogue.net/article/show/single/ch/3982-https://www.chinadialogue.net/article/show/single/ch/3982-Moving-past-Mexico1

他们的作品。 我没有任何'重写'我重新启动nginx但没有。 我不知道下一步该做什么。

I am using nginx and Pushion passenger. If I request this resource https://www.chinadialogue.net/article/show/single/ch/3982-Moving-past-Mexico I get a 404 from nginx instead of hitting Rails. I checked the logs. Rails is using SLUGs so anything after 3982 (article ID) still returns 3982, try:

https://www.chinadialogue.net/article/show/single/ch/3982- https://www.chinadialogue.net/article/show/single/ch/3982-Moving-past-Mexico1

They wall works. I do not have any 'rewrite' I restarted nginx but nothing. I am not sure what to do next.

最满意答案

首先,我们必须确定请求是否确实没有到达Rails,或者你的slug实现是否出现问题。

查看rails log(log / production.log)并点击返回404的URL。

你看到请求进来了吗? 或者什么也没有显示出来。

如果没有任何显示,您将知道您必须进一步调查您的nginx配置。

如果确实显示了某些内容,并且它看起来像是正确的控制器和正确的操作,那么您将获得有关在rails应用程序中进一步调查的位置的线索。

也可能是rails应用程序中的路由有一定的约束(也许以整数结束?)

如果没有关于您的设置的更多信息,则无法获得明确的答案。

First we have to find out if the request is indeed not reaching Rails or if something is going wrong with your slug implementation.

Look in your rails log (log/production.log) and hit the URL that returns the 404.

Do you see the request come in? Or does nothing show up at all.

If nothing shows up you'll know that you have to investigate your nginx configuration further.

If something does show up, and it looks like it's going to the right controller and the right action then you'll have a clue of where to investigate further in your rails app.

It could also be that the routes in your rails app have a certain constraint (ending in integer perhaps?)

Without more information about your setup, getting a definitive answer is not possible.

更多推荐

本文发布于:2023-07-26 00:26:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1268408.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:转发给   而不是   nginx   request   farwarding

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!