gpt4 book ai didi

ruby-on-rails-5 - AWS EBS - Rails5/nginx - robots.txt 未找到错误 (404)

转载 作者:行者123 更新时间:2023-12-04 12:44:44 24 4
gpt4 key购买 nike

我使用 AWS EBS 部署了一个非常标准的 Rails 5 应用程序。我的 /robots.txt 无法访问,对其 URL 的请求返回 404 错误。

我把它和404.html422.html500.html放在了/public文件夹中code> 页面,由 nginx 正确提供。

有什么问题的线索吗?我应该检查什么?

EB CLI 3.14.6(Python 2.7.1)

Ruby 2.4.3/Rails 5.1.4/Puma (gem) 3.7

最佳答案

看起来 4 年前在官方 AWS 论坛上提出了一个非常相似的问题:https://forums.aws.amazon.com/thread.jspa?threadID=150904

仅仅 4 年后,一位来自 AWS 的勇敢的人介入并给出了答复!下面是引用的回复:

Hello hello! I'm Chris, the new Ruby platforms person at Elastic Beanstalk. Visiting this thread today, it looks like there's been a lot of pain (and also confusion!) from Beanstalk's Ruby+Puma's handling of static files.

Quick summary: When this thread was created (in 2014), Beanstalk was essentially using the default Nginx that comes with Amazon Linux, with only some logging modifications to support the health monitoring. That spawned this thread, as static files are generally expected to be served the the web server when one is present.

So, the folks here went and fixed the /assets folder. Great! Unfortunately, there was a misunderstanding with the request to fix serving the /public folder - Beanstalk's Puma platform instead serves things in '/public' from '/pubilc', not from '/'. This is definitely an issue, so here's some workarounds:

Workaround 1: Turning on serve static assets. Yes, this wastes some application threads here or there, but if your use case is only robots.txt and favicon.ico, you're only robbing a couple of appserver threads. I'd pick this one unless I was running my application servers hot.

Workaround 2: Write an .ebextension to modify the Nginx configuration to serve /public at /. I'm in the process of writing one, so I'll tack it as a reply to this when I've given it the thought it deserves. Some of the current ones may serve your app's code, so double check the configuration if you've already done this workaround.

I've created a tracking issue for the team with this level of detail, so we'll work to get this corrected. Thank you all for your feedback - we'd love to serve you and your apps better.

此后,再无回复;如果有人知道使用 .ebextensions 编辑 nginx 配置的“aws-approved-way”,请在此处发布! :)

关于ruby-on-rails-5 - AWS EBS - Rails5/nginx - robots.txt 未找到错误 (404),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53001370/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com