D
D
Dmitry Bannik2016-02-14 19:43:29
Nginx
Dmitry Bannik, 2016-02-14 19:43:29

How to properly configure nginx upstream?

There are 6 web servers with unique content (static files)
I want to combine them all into 1 web server with file caching
fe225922abcd456da668795d6cc8a6cb.png
here is the code that I put together
but it turned out to be not an ideal solution

upstream backend {
    server 1.1.1.1:80;
    server 2.2.2.2:80;
    server 3.3.3.3:80;
    server 4.4.4.4:80;
    server 5.5.5.5:80;
    server 6.6.6.6:80;
}

server {
    listen 80;
    server_name dl.site.com;
        root    /var/www;

        location / {
                error_page         404 = @none;
        }

        location @none {
                internal;
                proxy_pass         http://backend;
                proxy_store        on;
                proxy_temp_path    /var/www;
        }
}

the required file is only in 3.3.3.3:80/file3 the
first time you access dl.site.com/file3 it gives 404
if you make a request for a file several times, then in some cases it will be downloaded (which is not acceptable)
nginx went through all 6 servers and downloaded the file ?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vlad Zhivotnev, 2016-02-15
@prodimon

upstream backend {
    server 1.1.1.1:80;
    server 2.2.2.2:80;
    server 3.3.3.3:80;
    server 4.4.4.4:80;
    server 5.5.5.5:80;
    server 6.6.6.6:80;
}

    location / {
      proxy_pass http://backend;
      proxy_set_header Host $host;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Forwarded-Proto $scheme;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_next_upstream error timeout http_404;
    }

Something like this.

M
Madnezz, 2016-02-14
@madnezz

Make dl1.site.com, dl2.site.com, dl3.site.com, dln.site.com and already point to dl3.site.com/file3 in the links and proxy these requests

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question