Images not loading sometimes with NGINX as RP

Hello NGINX users and devs,

it’s not the first time now, that I have the problem that some images
are just not loading sometimes (only after a few refreshes, gif images
in this case) with NGINX as reverse proxy. I haven’t figured out yet
why, I’ve had this problem with the old 0.x branch a few years ago, even
with the default config and now I have the same problem with the 1.x
branch and an advanced config with caching enabled (doesn’t matter if I
enable or disable it, have already tried that). Has anyone had the same
problem before or has a clue why that could be?


Posted at Nginx Forum:


In order to be able to assist you we need the config. Without it it’s
shooting in the dark.


As I said, I’ve also had this before with the default config. Anyway,
here you go:


user nginx;
worker_processes 6;
worker_rlimit_nofile 8000;

error_log /var/log/nginx/error.log;

pid /var/run/;

events {
worker_connections 4096;
use epoll;

http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
open_file_cache max=60000 inactive=300s;
open_file_cache_valid 360s;
open_file_cache_min_uses 2;
open_file_cache_errors off;
server_names_hash_bucket_size 64;

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;

client_body_temp_path /var/spool/nginx-client-body 1 2;
client_max_body_size 32m;
client_body_buffer_size 128k;
client_header_buffer_size 2k;
large_client_header_buffers 4 16k;

server_tokens  off;

sendfile       on;
tcp_nopush     on;
tcp_nodelay    off;

keepalive_timeout     3;
keepalive_requests   10;
client_body_timeout   5;
client_header_timeout 5;
send_timeout          5;

proxy_cache_path /var/cache/nginx levels=1:2

keys_zone=nginxcache:10m inactive=10m max_size=1000m;
proxy_temp_path /var/cache/nginx/proxy;
proxy_cache_key “$scheme://$host$request_uri”;

gzip on;
gzip_http_version 1.0;
gzip_comp_level 1;
gzip_proxied any;
gzip_min_length  10;
gzip_buffers 16 8k;
gzip_types text/plain text/css application/x-javascript text/xml

application/xml application/xml+rss text/javascript;
gzip_disable “MSIE [1-6].(?!.*SV1)”;
gzip_vary on;

proxy_redirect off;

proxy_set_header   Host             $host;
proxy_set_header   X-Real-IP        $remote_addr;
proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
proxy_max_temp_file_size 0;

proxy_connect_timeout      30;
proxy_send_timeout         90;
proxy_read_timeout         90;

proxy_buffer_size          4k;
proxy_buffers              4 32k;
proxy_busy_buffers_size    64k;
proxy_temp_file_write_size 64k;

include /etc/nginx/conf.d/*.conf;



upstream server {
server weight=1 fail_timeout=30s;

server {
listen 80;
access_log /var/log/nginx/domain.com_access.log;
error_log /var/log/nginx/;

location / {
proxy_pass http://server;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_cache nginxcache;
proxy_cache_valid 200 30m;

location ~*

.(jpg|png|gif|jpeg|css|js|swf|doc|pdf|xls|ppt|docx|pptx|xlsx)$ {
proxy_cache_valid 200 30m;
expires 604800;
proxy_pass http://server;
proxy_cache nginxcache;


Posted at Nginx Forum: