E
E
enginegarry2015-12-21 16:43:48
Nginx
enginegarry, 2015-12-21 16:43:48

Pictures from subdomains, how to set up nginx?

There is a server at domain.com in the nginx-apache bundle, there are two more servers with nginx on sub1.domain.com and sub2.domain.com. How to configure nginx to redirect to sub1.domain.com/images and sub2.domain.com/images in turn when accessing domain.com/images? I would be grateful for any advice.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton B, 2015-12-21
@bigton

Very simple.
1. In http {} create upstream

upstream images {
        least_conn;
        server server1;
        server server2;
    }

2. In server {} create location
location ~ \.(png|jpg|gif)$ {
    proxy_pass http://$images;
    proxy_redirect http://$images/ /;   
    proxy_intercept_errors on;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question