nginx根据URL分流
来源:互联网 发布:光学镜头的优化设计 编辑:程序博客网 时间:2024/04/28 13:50
原理介绍
URL分流
Nginx根据URL分发的2种方法
nginx配置url重写
配置文件
nginx.conf
user root;#user nobody;worker_processes 1;#error_log logs/error.log;#error_log logs/error.log notice;error_log logs/error.log info;#error_log logs/error.log debug;pid /data/webapps/nginx/logs/nginx.pid;events { worker_connections 1024;}http { include mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; log_format simple '$http_x_realip - $request'; access_log logs/access.log; sendfile on; #tcp_nopush on; client_max_body_size 0; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; ssi on; ssi_silent_errors on; include vhost/*.conf;}
erp.conf
upstream gray_server { server 0.0.4.96:8082 weight=5;}upstream real_server { server 0.0.4.95:8082 weight=5;}server { listen 9090; server_name erp.local.cn; access_log logs/erp_access.log main; include erp_gray_rewrite.conf; location /gray_rewrite { rewrite /gray_rewrite(.*) /$1 break; access_log logs/erp.log; error_log logs/erp.err; proxy_pass http://gray_server/; } location / { access_log logs/old_erp.log; error_log logs/old_erp.err; proxy_pass http://real_server/; }}
erp_gray_rewrite.conf
rewrite /(ab\.action.*) /gray_rewrite/$1 break;rewrite /(ac\.action.*) /gray_rewrite/$1 break;
命令行
启动
-c参数指定了要加载的nginx配置文件路径
cd sbin./nginx -c ../config/nginx.config
检查一下配置文件是否正确
以免重启后Nginx出现错误影响服务器稳定运行。判断Nginx配置是否正确命令如下:
nginx -t -c /usr/nginx/conf/nginx.conf 或者/usr/nginx/sbin/nginx -t
平滑重启nginx
nginx -s reload
阅读全文
0 0
- nginx根据URL分流
- nginx根据cookie分流
- nginx根据IP尾数分流,配置文件如下
- nginx跟据url进行分流
- nginx里添加图片分流
- nginx根据Url发送文件解析
- nginx rewrite和根据url参数location
- nginx 的几种分流方案
- nginx 根据不同URL分发到不同服务器
- python分析nginx日志根据共性url屏蔽ip
- 【Nginx】下载,请求限流限速,根据URL参数限速
- nginx 根据不同url反向代理到不同服务器
- nginx 配置nginx.conf,负载均衡,逻辑分流
- 机顶盒+AP 根据VLAN进行数据分流 技术实现
- nginx 配置轮询分流-实现负载均衡【测试通过】
- nginx 配置轮询分流-实现负载均衡
- 关于nginx根据url进行负载分配即location部分的相关设置
- 用nginx做ws代理,并根据url参数选择后台服务器
- 会计零基础该看什么书?
- 楼盘介绍
- React Native布局常识与技巧 一
- github的简单入门操作
- 404. Sum of Left Leaves求树的所有左叶子节点的和
- nginx根据URL分流
- CodeForces
- 项目简介
- QT中如何实现XML文件的创建、增加、修改、删除功能。
- 生活配套
- android 6.0检索本地各种类型的文件
- android 隐藏状态栏和修改状态栏的背景颜色(沉浸式状态栏)
- Vue1.x
- 【小狂系列】跟着小狂玩ESP32之编译环境搭建篇