nginx get request header

In the location configuration of nginx, when obtaining the header configuration, you need to add the fixed prefix "http_" to the header name, and change the underscore of "-" in the header name to underscore, for example:

E.g:

       The custom header name is X-TimerLocal, then use $http_x_timerlocal in nginx to get the value of X-TimerLocal.

       if ($http_x_timerlocal  = 'BIN') {

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

        }

The header request containing X-TimerLocal=BIN is judged. If the /timerbin/ path is found in the path, the request URL is rewritten and redirected. The above can be used for HTTPS conversion.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326112698&siteId=291194637