nginx 获取请求header

在nginx的location配置中,在获取header配置时,需要在header名称前面加上固定前缀“http_“,并将header名称中的“-”中划线变为下划线,举例说明:

例如:

       自定义的header名称为X-TimerLocal,那在nginx中使用$http_x_timerlocal 来获取到X-TimerLocal的值。

       if ($http_x_timerlocal  = 'BIN') {

              rewrite ^(.*/timerbin/.*)$ https://$host$1 permanent;

        }

包含X-TimerLocal=BIN的header请求进行判断,如果发现路径中包含/timerbin/路径时,对请求URL进行重写,重新跳转,以上可用做HTTPS转换使用

猜你喜欢

转载自timerbin.iteye.com/blog/2409931
今日推荐