🖥
Rails 4.2+: Rails + Unicorn, the solution when the content of the publ
Status
- If all of the following is in the 404 state, css, javascript and favicon are both invalid.
- public If you put the file directly below, but can not be accessed from the browser.
setting change
Change the Rails configuration file. (Rails 4.2.3)
- config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present? + config.serve_static_files = true
(In the original setting, the behavior is changed by the environment variable)
Then try restarting unicorn.
Settings seem to be different in Rails 4.1 or earlier . (Rails 4.1.0)
- config.serve_static_assets = false + config.serve_static_assets = true
The following article was referenced. Solution when the contents of the directory below public is 404 in Rails (Apache + Unicorn)
You can leave it to a web server without changing the unicorn settings. In the case of nginx, write location ~ ^/assets/
like this.
server { listen 80; server_name xxx.xxx.xxx.xxx; server_name example.com; root /path/to/public; location ~ ^/assets/ { root /path/to/public; } }
Original by
Rails 4.2以降: Rails+Unicorn で、publicディレクトリの中身が404になる場合の解決策
About
チャットメンバー募集
何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。
公開日時
2019-04-16
Discussion