B
B
borodka_lenina2016-06-16 11:38:42
Nginx
borodka_lenina, 2016-06-16 11:38:42

How to proxy a request to another node in case of receiving a 404?

Hello.
There are 2 servers, all requests go to the first one, it proxies some to the second one.
But sometimes 404 slips, that is, the server cannot find the required resource and gives an error. How to make 404 issued by the second server? That is, the first one does not find a picture in itself, sends us to the second one, the second one finds a picture in itself and shows it or does not find it, and then it gives out 404.

server {
    listen 443 ssl;

    server_name www.server.lan;

    ssl_certificate /etc/nginx/server.lan/ssl/server_pub.key;
    ssl_certificate_key /etc/nginx/server.lan/ssl/server_priv.key;

    proxy_set_header X-Original-Protocol $scheme;
    proxy_set_header Connection "";

    proxy_set_header Host www.server.lan;

    proxy_cache server_cache;
    proxy_cache_key $host$uri$is_args$args$http_origin$http_accept_encoding;

    access_log /var/log/nginx/server.lan.log ups buffer=64k flush=1m;

    set $server_stat_exp 180d;

    location / {
        gzip off;
        gzip_vary on;

        proxy_set_header X-Original-Protocol $scheme;
        proxy_set_header Connection "";
        proxy_set_header Host www.server.lan;

        proxy_pass http://localhost:3000;
    }

    location /test/ {
        proxy_cache off;
        proxy_set_header Host www.server.lan;
        proxy_pass http://10.10.10.1:3000/test/;
        proxy_intercept_errors on;
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Romanenko, 2016-06-16
@slimus

upstream?
nginx.org/ru/docs/http/ngx_http_upstream_module.ht...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question