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;
}
}
}
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;
}
}
}