Answer a question

I am having rails 4.1 application running with sidekiq on production. I have deployed it using nginx + unicorn. Also I have mounted sidekiq UI as follows,

mount Sidekiq::Web => '/sidekiq'

but since last few days when ever I try to access sidekiq UI, all assets of sidekiq returning 404, not found. But it was working previously fine. But not able to find what leads 404.

Here is my settings nginx+unicorn settings for my app

upstream sample_app {
  server unix:/tmp/sample_app.sock fail_timeout=0;
}

server {
  listen 80;
  server_name www.sample_app.com;

  root /home/deploy/applications/sample_app/current/public;

  # set expire to all assets
  location ~* \.(?:ico|css|js|gif|jpe?g|png|svg)$ {
    expires max;
  }

  try_files $uri/index.html $uri @sample_app;

  location @sample_app {
    proxy_set_header X-Request-Start "t=${msec}";
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_redirect off;
    proxy_pass http://sample_app;
  }

  error_page 500 502 503 504 /500.html;
  error_page 404 413 /404.html;
  client_max_body_size 50M;
  keepalive_timeout 10;
}

Answers

After debugging, I able to solve it by adding following line

# set expire to all assets
location ~* \.(?:ico|css|js|gif|jpe?g|png|svg)$ {
  expires max;
  try_files $uri @sample_app;
}
Logo

开发云社区提供前沿行业资讯和优质的学习知识,同时提供优质稳定、价格优惠的云主机、数据库、网络、云储存等云服务产品

更多推荐