zl程序教程

您现在的位置是:首页 >  其它

当前栏目

自定义header参数时的命名要求

参数 自定义 命名 要求 header
2023-09-11 14:22:41 时间

HTTP头是可以包含英文字母([A-Za-z])、数字([0-9])、连接号(-)hyphens, 也可义是下划线(_)。在使用nginx的时候应该避免使用包含下划线的HTTP头。主要的原因有以下2点。
1.默认的情况下nginx引用header变量时不能使用带下划线的变量。要解决这样的问题只能单独配置underscores_in_headers on。
2.默认的情况下会忽略掉带下划线的变量。要解决这个需要配置ignore_invalid_headers off。

 

 

http {
    include       mime.types;
    default_type  application/octet-stream;
    log_format  main  '$http_orig_client_ip - $remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"  "$upstream_addr" ';
    sendfile        on;
    underscores_in_headers on;
    ignore_invalid_headers  off;
    keepalive_timeout  65;
 upstream test2081{
    server 10.209.128.28:2081;
}