我的页面上有一些图像会在Safari中丢失,控制台中的信息Failed to load resource: The network connection was lost. 图片服务器是不同的域名,我可以通过在其他浏览器标签中粘贴url来正确地看到图片。
我发现这个https://gist.github.com/voronianski/791ef517c5392d7ce5fb但我不知道如何解决?
https://stackoverflow.com/questions/27828576/unable-to-turn-off-chunked-transfer-encoding-in-nginx-with-gzip-for-static-asset
http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; keepalive_timeout 65; open_file_cache max=102400 inactive=20s; open_file_cache_valid 30s; reset_timedout_connection on; send_timeout 2; gzip on; gzip_comp_level 5; gzip_min_length 256; gzip_proxied any; gzip_vary on; .... server { listen 80; server_name domain www.domain; access_log /var/log/nginx/domain.access.log; location /robots.txt { alias /var/www/html/domain/app/robots.txt; } location ~ ^/(images/|javascripts/|stylesheets/|fonts) { root /var/www/html/domain/app/assets; access_log off; expires max; } location / { set $fixed_destination $http_destination; if ( $http_destination ~* ^https(.*)$ ) { set $fixed_destination http$1; } proxy_pass http://127.00.0.1:8005/; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Destination $fixed_destination; client_max_body_size 50M; client_body_buffer_size 512k; proxy_connect_timeout 300; proxy_send_timeout 300; proxy_read_timeout 300; proxy_buffer_size 4k; proxy_buffers 4 32k; proxy_busy_buffers_size 64k; proxy_temp_file_write_size 64k; } }
sub.domain下的图像服务器
server { listen 80; server_name sub.domain www.sub.domain; access_log /var/log/nginx/sub.domain.access.log; location /robots.txt { alias /var/www/html/sub.domain/app/robots.txt; } location ~ ^/(images/|javascripts/|stylesheets/|fonts) { root /var/www/html/sub.domain/app/assets; access_log off; expires max; } location / { set $fixed_destination $http_destination; if ( $http_destination ~* ^https(.*)$ ) { set $fixed_destination http$1; } proxy_pass http://127.00.0.1:8006/; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Destination $fixed_destination; client_max_body_size 50M; client_body_buffer_size 512k; proxy_connect_timeout 300; proxy_send_timeout 300; proxy_read_timeout 300; proxy_buffer_size 4k; proxy_buffers 4 32k; proxy_busy_buffers_size 64k; proxy_temp_file_write_size 64k; } }
UPDATE
我将图像文件夹复制到相同的域进行testing,但仍然得到相同的错误,我以不同的分辨率存储图像,所以我testing如果我select所有较小的尺寸,它的工作。 如何解决这个问题? 我想念什么? 我应该增加keepalive_timeout还是什么?
我通过增加从2到60的send_timeout来解决这个问题,它可以正确地获取所有图像。 可以增加send_timeout ,正确的方法解决这个问题?