0

我正在开发一个 Web 应用程序,它必须提供一些静态 pdf 文件。一切都在桌面和 iOS 上运行良好,但静态文件不会在 Android 上下载。它只是挂起下载。这是外观的屏幕截图:

https://www.dropbox.com/s/r3qz9cia9vwwgam/2012-08-22%2020.38.37.png

安卓版本为 4.1.1

nginx版本是:

$ /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.2.3
built by gcc 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) 
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx-1.2.3 --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module

这是 nginx 配置的主要部分:

server {
    server_name .foosite.com;
    listen 443;

    ssl on;
    ssl_certificate /etc/ssl/certs/foo.crt;
    ssl_certificate_key /etc/ssl/private/foo.key;

    access_log logs/foo.log;

    gzip                on;
    gzip_http_version   1.0;
    gzip_comp_level     2;
    gzip_proxied        any;
    gzip_min_length     1100;
    gzip_buffers        16 8k;
    gzip_types          text/plain text/html text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;

    # Some version of IE 6 don't handle compression well on some mime-types, so just disable for them
    gzip_disable "MSIE [1-6].(?!.*SV1)";

    # Set a vary header so downstream proxies don't send cached gzipped content to IE6
    gzip_vary on;

    location / {
        # some proxy_pass stuff here        
    }

    location /media {
        alias   /foo/path/to/media/;
        expires 1y;
    }
}

这是我使用 curl 得到的响应标头:

$ curl -I https://foosite.com/media/path/to/foopdf.pdf
HTTP/1.1 200 OK
Server: nginx/1.2.3
Date: Thu, 23 Aug 2012 00:40:16 GMT
Content-Type: application/pdf
Content-Length: 136833
Last-Modified: Wed, 22 Aug 2012 21:14:50 GMT
Connection: keep-alive
Expires: Fri, 23 Aug 2013 00:40:16 GMT
Cache-Control: max-age=31536000
Accept-Ranges: bytes

我还尝试通过提供用户代理标头来模仿我的 chrome android 浏览器:

$ curl -A "Mozilla/5.0 (Linux; Android 4.1.1; Nexus 7 Build/JRO03D) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166  Safari/535.19" -I https://foosite.com/media/path/to/foopdf.pdf
HTTP/1.1 200 OK
Server: nginx/1.2.3
Date: Thu, 23 Aug 2012 00:33:09 GMT
Content-Type: application/pdf
Content-Length: 136833
Last-Modified: Wed, 22 Aug 2012 21:14:50 GMT
Connection: keep-alive
Expires: Fri, 23 Aug 2013 00:33:09 GMT
Cache-Control: max-age=31536000
Accept-Ranges: bytes

关于为什么会发生这种情况的任何想法?同样,这个问题只影响我所有的安卓设备(Galaxy Nexus 和 Nexus 7)。在桌面和 iOS 设备上运行良好。如果我禁用 SSL 并通过端口 80 提供服务,那么一切正常。

谢谢你。

4

0 回答 0