I am using nginx plus and need to pass the host as header variable, if no value is passed in header the default host should be used. Below my nginx.conf, Can anybody help me with the config
http {
resolver 172.10.0.10 valid=10s ipv6=off;
upstream demo {
zone demoservers 64k;
server demo-server.com:443 resolve;
}
server {
listen 443 ssl;
location / {
proxy_pass https://demo-server.com;
proxy_ssl_server_name off;
}
}
server {
listen 8080;
location /api {
api write=off;
# directives limiting access to the API
}
location = /test.html {
root /usr/share/nginx/html;
}
# Redirect requests made to the pre-NGINX Plus API dashboard
location = /test1.html {
return 301 /test.html;
}
}
}
map $host $destination {
host1.com 192.168.1.1;
host2.com 192.168.1.2;
default 192.168.1.254;
}
Then you can use it in proxy_pass
location / {
proxy_pass https://$destination;
proxy_ssl_server_name off;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.