 
   access_log /var/www/ekade/logs/nginx/static-access.log combined buffer=32k;
   error_log  /var/www/ekade/logs/nginx/static-error.log;
-  
+
   location ~ ^/email/[^/]+/.*\.jpe?g$ {
     rewrite ^/email/([^/]+)/.* /public/Slike/$1/Email break;
-    proxy_pass http://127.0.0.1:6081;
-    proxy_set_header REMOTE_ADDR $remote_addr;
-    proxy_set_header X-Real-IP $remote_addr;
-    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
-    proxy_set_header HOST $host;
-  }
-  
+    proxy_pass http://images-upstream;
+    proxy_set_header REMOTE_ADDR $remote_addr;
+    proxy_set_header X-Real-IP $remote_addr;
+    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+    proxy_set_header HOST $host;
+  }
+
   location ~ ^/thumbnail/[^/]+/.*\.jpe?g$ {
     rewrite ^/thumbnail/([^/]+)/.* /public/Slike/$1/Thumbnail break;
-    proxy_pass http://127.0.0.1:6081;
-    proxy_set_header REMOTE_ADDR $remote_addr;
-    proxy_set_header X-Real-IP $remote_addr;
-    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
-    proxy_set_header HOST $host;
-  }
-  
+    proxy_pass http://images-upstream;
+    proxy_set_header REMOTE_ADDR $remote_addr;
+    proxy_set_header X-Real-IP $remote_addr;
+    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+    proxy_set_header HOST $host;
+  }
+
   location ~ ^/web/[^/]+/.*\.jpe?g$ {
     rewrite ^/web/([^/]+)/.* /public/Slike/$1/Web break;
-    proxy_pass http://127.0.0.1:6081;
-    proxy_set_header REMOTE_ADDR $remote_addr;
-    proxy_set_header X-Real-IP $remote_addr;
-    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
-    proxy_set_header HOST $host;
-  }
-  
+    proxy_pass http://images-upstream;
+    proxy_set_header REMOTE_ADDR $remote_addr;
+    proxy_set_header X-Real-IP $remote_addr;
+    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+    proxy_set_header HOST $host;
+  }
+
   location ~ ^/kade/.* {
     root /var/www/ekade;
     expires 30d;

  ssl_certificate_key /etc/certs/emajliramokade.com.key;

  client_max_body_size 10M;
  
  ssl_stapling on;
  resolver 8.8.8.8;
  ssl_verify_depth 1;

upstream images-upstream {
  server 127.0.0.1:6081;
  server 127.0.0.1:10080 backup;
}

server {
  listen static.emajliramokade.com:80;
  server_name static.emajliramokade.com;

  access_log /var/www/ekade/logs/nginx/plain-access.log combined buffer=32k;
  error_log  /var/www/ekade/logs/nginx/plain-error.log;

  location ~ ^/email/[^/]+/.*\.jpe?g$ {
    rewrite ^/email/([^/]+)/.* /public/Slike/$1/Email break;
    proxy_pass http://images-upstream;
    proxy_set_header REMOTE_ADDR $remote_addr;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header HOST $host;
  }

  location ~ ^/thumbnail/[^/]+/.*\.jpe?g$ {
    rewrite ^/thumbnail/([^/]+)/.* /public/Slike/$1/Thumbnail break;
    proxy_pass http://images-upstream;
    proxy_set_header REMOTE_ADDR $remote_addr;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto https;
    proxy_set_header HOST $host;
  }

  location ~ ^/web/[^/]+/.*\.jpe?g$ {
    rewrite ^/web/([^/]+)/.* /public/Slike/$1/Web break;
    proxy_pass http://images-upstream;
    proxy_set_header REMOTE_ADDR $remote_addr;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
