首页 > 系统相关 >会话丢失-NGINX配置之underscores_in_headers

会话丢失-NGINX配置之underscores_in_headers

时间:2022-11-27 00:34:10浏览次数:61  
标签:off 请求 NGINX underscores headers 下划线

1.描述
问题
NGINX代理某个web服务时,单机情况下也出现不停的要求认证的情况

初步分析
去掉NGINX代理,直接访问服务,未出现上述情况;

进一步分析:
查看经过NGINX的请求和直接访问服务请求区别:
cookie中的部分带下划线’_'的认证信息丢失导致,因此出现重复要求认证。

2.解决办法
在NGINX,配置文件http {} 模块中添加如下配置:

underscores_in_headers on;
1
重启NGINX服务,再次访问服务正常。

3.官方解释
Syntax: underscores_in_headers on | off;
Default: underscores_in_headers off;
Context: http, server

Enables or disables the use of underscores in client request header fields. When
the use of underscores is disabled, request header fields whose names contain underscores
are marked as invalid and become subject to the ignore_invalid_headers directive.

由官方解释可以看出,默认情况下,underscores_in_headers为off,表示当客户端请求头中带有下划线的字段默认将会被标识为无效字段。

因此,如下两个建议:

尽量不要在请求头中添加带下划线的字段;
使用NGINX代理的时候,添加underscores_in_headers on的配置

标签:off,请求,NGINX,underscores,headers,下划线
From: https://www.cnblogs.com/exmyth/p/16928720.html

相关文章

  • Nginx同域名下配置多个Vue项目
    #HTTPSserverserver{listen443;server_name************.com;sslon;ssl_certificatecert/*......
  • Nginx学习
    Nginx一为什么要用Nginx?我们之前有分析过,单台服务器可能会遇到的问题,比如服务器宕机,或者并发用户太多,单台服务器不够等问题,所以需要集群架构,就是将项目部署到多台......
  • 使用systemctl管理服务(nginx)
    http://www.manongjc.com/detail/26-gxlomozjeblpelj.html点击查看代码[Unit]Description=nginxAfter=network.target[Service]Type=forkingExecStart=/usr/local/......
  • CentOS7源码安装Nginx1.22
    CentOS7源码安装Nginx1.22一、安装下载源码包:wgethttp://nginx.org/download/nginx-1.22.1.tar.gz安装依赖:yum-yinstallgccmakepcrepcre-developensslope......
  • Dbian10编译nginx实验部署HTTP3(Quiche)
    https://zach.vip/web/dbian10%E7%BC%96%E8%AF%91nginx%E5%AE%9E%E9%AA%8C%E9%83%A8%E7%BD%B2http3/......
  • Ubuntu安装FastDFS(5.11版本)以及Nginx(1.22.1版本)
    主要步骤参见https://blog.csdn.net/allblueee/article/details/125990233其中Nginx版本与该博文不同,另外Nginxreload的时候如果出现如下问题:nginx:[error]open()"/u......
  • 前端学习 Nginx
    前端学习nginx本篇主要讲解nginx常用命令、基础概念(正向/反向代理、负载均衡、动静分离、高可用)、配置文件结构,并通过简单的实验来体验​​反向代理​​​和​​负载均衡......
  • Nginx的使用讲解
    Author:Ericversion:9.0.1 文章目录​​一、引言​​​​1.1代理问题​​​​1.2负载均衡问题​​​​1.3资源优化​​​​1.4Nginx处理​​​​二、Nginx概述​​​​三......
  • nginx过滤access_log中HEAD、OPTIONS请求记录
    网上很多教程说是这样做:if($request_method=HEAD){access_logoff;}试了之后是不行的,正确的做法如下:http{map$request_method$loggable{HEAD0;......
  • nginx过滤access_log中HEAD、OPTIONS请求记录
    网上很多教程说是这样做:if($request_method=HEAD){access_logoff;}试了之后是不行的,正确的做法如下:http{map$request_method$loggable{HEAD0;......