Nginx Routing Based on Header Upgrade
Some Command I need
>sudo sbin/nginx -s reload
Reload the configuration file and restart the nginx
>sudo sbin/nginx -t
Test and check if my statements in conf/nginx.conf is correct.
>sudo sbin/nginx
Just Start the nginx process
Here is my configuration.
location / {
proxy_pass http://contentcenter2;
if ($http_x_header) {
proxy_pass http://contentcenter1;
}
}
The idea is that first of all, make proxy_pass have default value.
Then check the header, if we have the customer header X_HEADER, we will go to another proxy_pass value, which point to another server URL.
References:
http://sillycat.iteye.com/blog/2074417
http://sillycat.iteye.com/blog/2074422
相关推荐
用Nginx向http request请求的http header中添加字段
大家都知道,nginx配置文件通过使用add_header指令来设置response header。 昨天无聊用curl查看一个站点的信息,发现返回的头部与想象中的不一样: HTTP/2 200 date: Thu, 07 Feb 2019 04:26:38 GMT content-type: ...
Windows版nginx去掉header中server后面的信息(nginx版本1.21.1) 使用方法: 1、关闭nginx服务 2、将新的nginx.exe替换原有的exe文件 3、重启nginx服务
而且在低版本的 nginx 中 add_header 还不支持在错误页面中使用。 这是一个坑比较多的指令。它的处理阶段比 location 处理晚,虽然可以写在 location 中,但如果 rewrite 别的 location,那么上一个 location 中...
开发网关项目时,在请求时往请求头header中放入了签名sign_key信息,在接收请求时再从header中拿出,在本地调试时是可以的,但上线之后通过Nginx代理之后发现拿不到。 location / { proxy_set_header X-Real-IP $...
因为系统需要websocket通信,但是服务器的... proxy_set_header Connection "Upgrade"; #proxy_set_header X-Real-IP $remote_addr; #proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
title: nginx解决Too-many-header问题在对接海康卫视WEB无插件开发包时,自己的页面连接单独的摄像头时(连接NVR没这个问题),/ISA
主要介绍了nginx add_header指令使用方法,nginx配置文件通过使用add_header指令来设置response header,需要的朋友可以参考下
nginx + header 转发 灰度测试
nginx 负载均衡与缓存服务器标准配置文件
How To Install nginx on CentOS 6 with yum
nginx 版本 1.11.3 使用大家说的以下配置,验证无效,跨域问题仍然存在 add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Allow-Credentials' 'true'; add_header 'Access-Control-Allow...
3.找到D:\nginx\conf下nginx.conf文件用记事本打开 在文段末尾大括号前加上 include proxy.conf;(就是加载刚刚新建的那个文件(注意路径)) 4.进入cmd 进入D盘: d: 进到nginx文件夹下:cd nginx 启动nginx.exe:...
nginx-1.9.12 windos 版本 nginx 反向代理 负载均衡
nginx 离线安装包nginx 离线安装包
nginx镜像资源nginx镜像资源nginx镜像资源nginx镜像资源nginx镜像资源nginx镜像资源
YUM upgrade升级:本方式适用于使用rpm安装nginx的方式,优点是升级操作简单便捷,缺点是无法升级到指定版本,默认升级至YUM安装支持的最新版本,当前最新版本为nginx1.18.0。 源码平滑升级升级:本方式适用于...