ruby-on-rails – 如何使用puma / nginx在资产管道中提供不属于/
发布时间:2020-12-17 01:20:56 所属栏目:百科 来源:网络整理
导读:这是一个AWS问题,我使用的是 Ruby 2.2(Puma)平台. 我编译的资产(in / public / assets)按预期方式提供. / public中的其他资产未被送达(404). 我在哪里配置?这是一个nginx问题吗?还是美洲狮问题? 还是这只是一个AWS图像问题? 这是一个实例(robots.txt应该
这是一个AWS问题,我使用的是
Ruby 2.2(Puma)平台.
我编译的资产(in / public / assets)按预期方式提供. / public中的其他资产未被送达(404). 我在哪里配置?这是一个nginx问题吗?还是美洲狮问题? 还是这只是一个AWS图像问题? 这是一个实例(robots.txt应该从根): 还值得一提的是,默认的Passenger平台图像是开箱即用的. 解决方法
如果它帮助任何人,或有人知道如何改进它,这里是nginx配置,终于得到它为我工作.在/.ebextensions/01_files.config中:
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 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |