简体   繁体   中英

How does nginx forward a header with a $ sign

A Http Request has a header : $name ,access nginx forward ,the header will lose ,but I need the header:$name,how can I config the nginx?

example:

    location /api/ {
        proxy_pass         http://127.0.0.1:8081/;
        proxy_redirect     off;
        proxy_set_header   Host $host;
        proxy_set_header   $name $http_$name;
    }

Escape dollar sign by creating a variable with it:

http {
    geo $dollar {
        default "$";
    }
    server {
        ...
        location /api/ { 
            proxy_pass http://127.0.0.1:8081/; 
            proxy_redirect off; 
            proxy_set_header Host $host; 
            proxy_set_header ${dollar}name $http_$name; 
        }
    }
}


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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM