Welcome! Log In Create A New Profile

Advanced

Re: Multiple proxy_pass destinations from a single location block

February 04, 2015 04:20AM
On 04 Feb 2015, at 12:11, justink101 <nginx-forum@nginx.us> wrote:

> Is it possible to specify multiple proxy_pass destinations from a single
> location block? Currently we have:
>
> location ~ ^/v1/?(?<url>.+)? {
> resolver 208.67.222.222 208.67.220.220 valid=300s;
> resolver_timeout 10s;
> proxy_intercept_errors off;
> proxy_hide_header Vary;
> proxy_set_header Host "foo.mydomain.io";
> proxy_set_header X-Real-IP $remote_addr;
> proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
> proxy_pass https://foo.mydomain.io/api/$url;
> proxy_connect_timeout 10s;
> proxy_read_timeout 60s;
> proxy_ssl_session_reuse on;
> proxy_ssl_trusted_certificate /etc/pki/tls/certs/ca-bundle.crt;
> proxy_ssl_verify on;
> proxy_ssl_verify_depth 2;
> proxy_ssl_ciphers "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM
> EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256
> EECDH+aRSA+RC4 EECDH EDH+aRSA RC4 !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK
> !SRP !DSS";
> }
>
> I'd like to keep all the above logic, but ALSO set up another proxy_pass
> from this location block to say bar.mydomain.com. What is the best way to do
> this?

The first thing you do not need regex here:

location /v1/ {
proxy_pass http://foo.mydomain.io/api/;
...
}

is enough.

To add another server to proxy_pass you can use upstream:

upstream mydomain {
server foo.mydomain.io;
server bar.mydomain.com;
}

server {
...
location /v1/ {
proxy_pass http://mydomain/api/;
...
}



--
Igor Sysoev
http://nginx.com

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Multiple proxy_pass destinations from a single location block

justink101 February 04, 2015 04:11AM

Re: Multiple proxy_pass destinations from a single location block

Igor Sysoev February 04, 2015 04:20AM

Re: Multiple proxy_pass destinations from a single location block

justink101 February 05, 2015 03:26AM

Re: Multiple proxy_pass destinations from a single location block

Igor Sysoev February 05, 2015 07:40AM

Re: Multiple proxy_pass destinations from a single location block

AmitChauhan March 13, 2015 06:16AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 164
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready