nginx proxy_pass不加载相对链接引用的图像

时间:2014-05-30 18:29:04

标签: nginx proxy reverse-proxy

我使用nginx作为github上托管的某些应用程序的反向代理,遇到了一个奇怪的问题。

页面和引用的JavaScript加载正常,但图像,例如:images / icon.png,未加载。我现在通过使用sub_filter重写相对链接以指向原始文件地址来解决这个问题。这比实际解决方案更具攻击性。

奇怪的是,Javascript库也被引用为相对链接,例如scripts / app.js,并且它正确加载。我想也许这可能是MIME类型的问题,但似乎无法在没有URL重写的情况下使图像工作。

这是位置代码段:

location ~* /app/data {
    rewrite ^/app/data/(.*)$ /app-data/$1 break;
    proxy_set_header Host myhost.github.io;
    proxy_pass http://myhost.github.io;
    gzip on;
    gzip_types text/xml;
    sub_filter_types text/html;
    sub_filter_once off;
    sub_filter \"img/ \"http://myhost.github.io/app-data/img/;
}

0 个答案:

没有答案