Nginx   发布时间:2022-05-11  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了ruby-on-rails – 如何使用puma / nginx在资产管道中提供不属于/ public的资产?大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

这是一个AWS问题,我使用的是Ruby 2.2(Puma)平台.

我编译的资产(in / public / assets)按预期方式提供. / public中的其他资产未被送达(404).

我在哪里配置?这是一个Nginx问题吗?还是美洲狮问题?

还是这只是一个AWS图像问题?

这是一个实例(robots.txt应该从根):
http://staging.us-West-2.elasticbeanstalk.com/public/robots.txt

还值得一提的是,默认的Passenger平台图像是开箱即用的.

最佳答案
如果它帮助任何人,或有人知道如何改进它,这里是Nginx配置,终于得到它为我工作.在/.ebextensions/01_files.config中:

@H_419_21@files: "/etc/Nginx/conf.d/webapp_healthd.conf" : mode: "000755" owner: root group: root content: | upstream my_app { server unix:///var/run/puma/my_app.sock; } log_format healthd '$msec"$uri"' '$status"$request_time"$upstream_response_time"' '$http_x_forWARDed_for'; server { listen 80; server_name _ localhost; # need to listen to localhost for worker tier root /var/app/current/PUBLIC; if ($time_iso8601 ~ "^(\d{4})-(\d{2})-(\d{2})T(\d{2})") { set $year $1; set $month $2; set $day $3; set $hour $4; } access_log /var/log/Nginx/access.log main; access_log /var/log/Nginx/healthd/application.log.$year-$month-$day-$hour healthd; try_files $uri/index.html $uri @my_app; LOCATIOn @my_app { proxy_pass http://my_app; # match the name of upstream directive which is defined above proxy_set_header Host $host; proxy_set_header X-ForWARDed-For $proxy_add_x_forWARDed_for; } LOCATIOn /assets { alias /var/app/current/public/assets; gzip_static on; gzip on; expires max; add_header Cache-Control PUBLIC; } } "/opt/elasticbeanstalk/hooks/appdeploy/post/03_restart_Nginx.sh": mode: "000755" owner: root group: root content: | #!/usr/bin/env bash rm /etc/Nginx/conf.d/webapp_healthd.conf.bak rm /etc/Nginx/conf.d/custom.conf service Nginx restart

大佬总结

以上是大佬教程为你收集整理的ruby-on-rails – 如何使用puma / nginx在资产管道中提供不属于/ public的资产?全部内容,希望文章能够帮你解决ruby-on-rails – 如何使用puma / nginx在资产管道中提供不属于/ public的资产?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: