Nginx Manage the Cookie in Response
My requirement is to delete the Response Cookie in my NGINX.
At first, I was trying
proxy_hide_header Set-Cookie
It can remove the response header Set-Cookie. So the HTTP response will not have this in the header.
But actually, my requirement is to delete one Cookie. So I change to do like this.
add_header 'Set-Cookie' 'VC=;Path=/api;Domain=.sillycat.com;Max-Age=0;Expires=0';
add_header 'Set-Cookie' 'VC=;Path=/DWH/accounts;Domain=.sillycat.com;Max-Age=0;Expires=0';
These lines means, it will remove the VC cookie in that path.
The full information in NGINX is similar to
location /DWH {
index index.html;
proxy_pass https://{{proxy_server}}.{{target_domain}};
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
add_header 'Access-Control-Allow-Origin' $http_origin;
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Credentials' 'true';
#proxy_hide_header Set-Cookie;
add_header 'Set-Cookie' 'VC=;Path=/api;Domain=.{{target_domain}};Max-Age=0;Expires=0';
add_header 'Set-Cookie' 'VC=;Path=/DWH/accounts;Domain=.{{target_domain}};Max-Age=0;Expires=0';
}
I am using a Python template, so I have {{}} there. But the idea is the same.
In the browser, we can go to developer tool —> Application —> Cookies to see the changes.
References:
https://blog.confirm.ch/adding-and-removing-nginx-response-headers/
https://github.com/openresty/headers-more-nginx-module
https://stackoverflow.com/questions/35493418/how-to-remove-a-response-header-in-nginx-after-having-stored-its-value-in-case-o
http://www.ebrueggeman.com/blog/setting-cookies-in-nginx
http://mailman.nginx.org/pipermail/nginx/2016-September/051736.html
分享到:
相关推荐
另一方面,`upstream_response_time` 是用来跟踪从Nginx与上游服务器建立连接到接收完整响应并关闭连接的时间。这个时间仅包括了Nginx与后端服务器之间的交互,不包含客户端的网络延迟和Nginx自身的处理时间。格式...
The Complete NGINX Cookbook The Complete NGINX Cookbook The Complete NGINX Cookbook The Complete NGINX Cookbook The Complete NGINX Cookbook
Nginx-sticky模块(基于cookie的负载均衡实现)及追加安装注意事项
其他系统可以共享这个cookie。但是新的四台服务器中并没有申请域名,只有四个ip: 192.168.0.1 单点登录服务器 192.168.0.2 192.168.0.3 192.168.0.4 因为每台服务器有两个项目,都用到单点登录,所以通过修改新的...
**Nginx与Cookie有效期管理** Cookie在Web应用程序中扮演着关键角色,主要用来存储用户状态,特别是身份验证信息。然而,如果不正确地管理和配置,Cookie可能会成为安全风险的源头。本文将深入探讨Cookie的工作原理...
*) Bugfix: when using HTTP/2 nginx might return the 400 response without logging the reason. *) Bugfix: in processing of corrupted cache files. *) Bugfix: cache control headers were ignored when...
the licensed version of NGINX that provides many advanced features, such as a real-time monitoring dashboard and JSON feed, the ability to add servers to a pool of application servers with an API call...
*) Bugfix: a segmentation fault might occur in a worker process if resolver got a big DNS response. *) Bugfix: in cache key calculation if internal MD5 implementation was used; the bug had appeared in...
Sticky是nginx的一个模块,它是基于cookie的一种nginx的负载均衡解决方案,通过分发和识别cookie,来使同一个客户端的请求落在同一台服务器上,默认标识名为route (a)客户端首次发起访问请求,nginx接收后,发现...
《Nginx实战:高性能Web服务器的安装与部署及实现原理》 Nginx是一款流行的开源Web服务器,以其高性能、高并发和低内存消耗而受到广大开发者和运维人员的青睐。它采用事件驱动的异步非阻塞模型,能够有效地处理大量...
In doing so you will learn how to tune NGINX for various situations, what some of the more obscure configuration options do, and how to design a decent configuration to match your needs. You will no ...
Windows版nginx去掉header中server后面的信息(nginx版本1.21.1) 使用方法: 1、关闭nginx服务 2、将新的nginx.exe替换原有的exe文件 3、重启nginx服务
《Nginx Cookbook》是那些希望深化对Nginx理解的IT专业人士的宝贵资源。本书分为三个主要部分,每一部分都为读者提供了从基本到高级的实用知识,涵盖了Nginx配置、管理和优化的各个方面。 **第一部分:负载均衡与...
**Nginx Cookie模块详解** 在Web服务器领域,Nginx以其高性能、轻量级的特点深受青睐,尤其在处理高并发请求时表现出色。而Nginx的Cookie模块则是其功能扩展的重要部分,用于处理HTTP请求中的cookie信息,实现用户...
NGINX is one of the most widely used web servers available today, in part because of its capabilities as a load balancer and reverse proxy server for HTTP and other network protocols. The 2019 edition...
arm 架构 docker运行nginx镜像包,arm 架构 docker运行nginx镜像包,arm 架构 docker运行nginx镜像包,arm 架构 docker运行nginx镜像包,arm 架构 docker运行nginx镜像包,arm 架构 docker运行nginx镜像包,arm 架构...
在Nginx配置中添加Cookie信息到日志记录是一个实用的方法,可以帮助监控和分析用户行为。以下是关于如何在Nginx日志中增加Cookie信息的详细步骤和知识点: 1. **获取全部Cookie信息** 在Nginx的主配置文件`nginx....