I couldn't understand the cause and got stuck, so I'd like to ask you a question.
The title is correct.
I am deploying to the server after running assembets:precompile locally, but I am having trouble because the manifest file is not reflected.
(Only images are reflected, but stylesheets and javascripts are not.)
Below are the things I have confirmed.
↓ reflects css, but
<link rel="stylesheet" media="all" href="http://localhost:3000/assets/application-34ad617bfadb73ed23d5a75.cs"data-turbolinks-track="true">
↓ does not reflect css
<link rel="stylesheet" media="all" href="http://ec2-****.ap-northeast-1.compute.amazonaws.com/assets/application-34ad617bfadb73ed23d5a75.css"data-turbolinks-track="true">
This situation (both of them are exactly the same), except that the server is different between the local and AWS environments.We use WEBrick locally and Nginx+Unicorn in AWS environments.
Based on this, I thought that the setting of Nginx might be suspicious, so I have tried many things, but it has not been improved.The following are the settings for /etc/nginx/nginx.conf, the relevant settings for production.rb, and the operating environment:
Thank you for your advice.
events{
worker_connections2048;
}
US>http{
upstream unicorn {
server unix: /tmp/unicorn.sock;
}
server{
listen80;
server_name localhost;
root/var/www/app;
error_log/var/www/app/log/nginx.log;
location~^/assets/{
root/var/www/app/public;
}
location / {
if (-f$request_filename) {break;}
proxy_set_header X-Real-IP$remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_pass http://unicorn;
}
}
}
-
config.serve_static_files=ENV['RAILS_SERVE_STATIC_FILES'].present?
config.assets.compile=false
config.assets.digest=true
-
It's not an answer, it's a question.
Questions
server_name localhost;
Therefore, I wonder if this conf is not used.
Does the server name match localhost?
Is there a possibility that other nginx.conf is starting?
However,
You can see it even if you type the URL directly.
Unicorn
So it may not matter.
As part of the problem isolation, it would be good if you could confirm it.
http://ec2-****.ap-northeast-1.compute.amazonaws.com/assets/application-34ad617bfadb73ed23d5a75.css
You can infer that the html that rails render is incorrect, since you can see that you hit directly.
You may find the problem by looking at the links that rails on the server output.
© 2024 OneMinuteCode. All rights reserved.