繁体   English   中英

Nginx代理服务器不在Rails应用程序上提供静态资产

[英]Nginx proxy server not serving static assets on rails app

我遵循了一些答案,在此做了对location块的更改以服务于静态资产。 似乎没有运气。

/ etc / nginx / sites-enabled / default

server {
    listen 80 default_server;
    listen [::]:80 default_server;

    root /var/www/html;

    index index.html index.htm index.nginx-debian.html;

    server_name _;

    location / {
    proxy_pass http://127.0.0.1:3000;
        # First attempt to serve request as file, then
        # as directory, then fall back to displaying a 404.
        try_files $uri $uri/ =404;
    }

  location ~* /(assets|fonts|swfs|images)/ {
    gzip_static on;
    expires max;
    add_header Cache-Control public;
  }

}

有人可以帮我解决此问题吗?

如果资产的文件夹位于/var/www/html ,例如/var/www/html/images/test.jpg/var/www/html/images/test.jpg使用以下语法:

location ^~ /(assets|fonts|swfs|images)/ {
    access_log  /var/log/nginx/test.com.access_proxy.log;
    error_log  /var/log/nginx/test.com.error_proxy.log;
    root       /var/www/html/;
    internal;
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM