nginx负载均衡图片无法加载

下面是我的负载平衡configuration。我的其他服务器包含基于nginx独angular兽的应用程序设置。 当我尝试以上configuration图像不加载。 我总共有三个服务器1负载平衡和其他2个应用程序。 有人可以帮我弄这个吗。 我完全感到震惊。

upstream backend { server ws1.10.10.1.1 fail_timeout=10; server ws2.10.10.1.2 fail_timeout=5; } server { listen 80; client_max_body_size 2G; server_name staging.xxxx.com; include /etc/nginx/mime.types; default_type application/octet-stream; location / { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X_FORWARDED_PROTO $scheme; proxy_set_header Host $host; proxy_connect_timeout 3; proxy_read_timeout 60; proxy_send_timeout 60; proxy_redirect false; proxy_max_temp_file_size 0; if (!-f $request_filename) { proxy_pass http://backend; } } location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ { } } 

如果你想通过代理服务器提供服务,问题是当URI匹配时,正则expression式位置块在nginx位置的search中具有更高的优先级。 所以,删除最后一个位置块或写一个独特的回退位置,并使用try_files

 open_file_cache max=10 inactive=10m; open_file_cache_valid 5m; open_file_cache_min_uses 1; open_file_cache_errors on; location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ { # other stuff try_files /unreachable/path @fallback; } location / { # other stuff try_files /unreachable/path @fallback; } location @fallback { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X_FORWARDED_PROTO $scheme; proxy_set_header Host $host; proxy_connect_timeout 3; proxy_read_timeout 60; proxy_send_timeout 60; proxy_redirect false; proxy_max_temp_file_size 0; proxy_pass http://backend; } 

我自己修复它的问题是我应该在application.rb中添加负载平衡url以及seeeion_store.rb错误我添加本地主机,所以它无法获得图像现在它的固定。