I have mounted Sidekiq in a sub-folder as follows:
admin_constraint = lambda { |request| request.env["warden"].authenticate? and request.env['warden'].user.admin_rights? }
constraints admin_constraint do
mount Sidekiq::Web => '/bunker/sidekiq'
end
Locally this works fine, however when I push to my staging or production servers I get 404 errors on those assets when trying to view the Sidekiq admin interface.
An example URL that returns a 404 is http://my-domain.com/my-folder/sidekiq/stylesheets/bootstrap.css
I am on Rails 3.2.11, I am using Rack::ForceDomain and Rack::Deflated middleware.
I am tempted to just serve those files locally and create my own manual routes, but that does seem unnecessary. Shout if you want any further information to help diagnose the issue.
Thanks,
Matt
Did you see the FAQ?
https://github.com/mperham/sidekiq/wiki/FAQ#why-dont-cssjsimg-assets-load-properly-when-i-go-to-sidekiqs-web-ui
You're a legend, and sorry for not scouring the FAQs sufficiently. Thanks for the quick response.
Also check out your config.action_dispatch.x_sendfile_header. I've spend a lot of time, and finally found that I have to remove this setting. But a good thing, now I know an internals of Sinatra, Sidekiq-web and Rack::File :)
Hi,
I added code to nginx.conf as described in FAQ but I am getting this error:
nginx: [emerg] invalid number of arguments in "try_files" directive in /etc/nginx/sites-enabled/default:18
nginx: configuration file /etc/nginx/nginx.conf test failed
My code looks like this:
server {
listen 80 default deferred;
server_name xxxxxxxxx.xxxx.xxxxx;
access_log /home/deployer/apps/dashboard/shared/log/localhost.access.log;
location / {
include /etc/nginx/proxy_params;
proxy_set_header X-Real-IP $remote_addr;
}
location ~ ^/assets/ {
try_files $uri;
}
}
Do you have any clue? I will appreciate your help.
The try_files directive takes a fallback location as the last parameter. It requires at least two parameters, as you can see in the official documentation. Often you put try_files outside of the location block instead. Something more like this:
try_files $uri @app;
location ~ ^/(assets)/ {
gzip_static on;
expires max;
add_header Cache-Control public;
log_not_found off;
}
location @app {
# put your proxy params here
}
There are infinite possibilities, tons of documentation and plenty of recipes out there.
Most helpful comment
The
try_filesdirective takes a fallback location as the last parameter. It requires at least two parameters, as you can see in the official documentation. Often you puttry_filesoutside of the location block instead. Something more like this:There are infinite possibilities, tons of documentation and plenty of recipes out there.