Quantcast
Channel: Nginx Forum - How to...
Viewing all articles
Browse latest Browse all 4759

How to proxy_pass based on HTTP headers?

$
0
0
I'm wondering how I can use HTTP headers and based on those headers I would like to proxy_pass it to different servers?

For example if the HTTP "accept" header is set to "text/html" then I want to proxy_pass to server 1, and otherwise to server 2.

I'm looking for something like this but don't know how to do it.

server {
listen 80;
server_name www.test.io;

location / {
IF HTTP HEADER accept == "text/html" {
proxy_pass http://your_server_ip:443;
} else {
proxy_pass http://your_server_ip:8080;
}
}
}

Viewing all articles
Browse latest Browse all 4759

Trending Articles