您的位置:首页 > 汽车 > 时评 > python自学免费教程_甜蜜蜜西瓜视频免费观看_整合营销策划名词解释_跨境电商营销推广

python自学免费教程_甜蜜蜜西瓜视频免费观看_整合营销策划名词解释_跨境电商营销推广

2024/10/22 11:00:53 来源:https://blog.csdn.net/pymzy666skr/article/details/143063703  浏览:    关键词:python自学免费教程_甜蜜蜜西瓜视频免费观看_整合营销策划名词解释_跨境电商营销推广
python自学免费教程_甜蜜蜜西瓜视频免费观看_整合营销策划名词解释_跨境电商营销推广


upstream_check模块 

 


配置文件详情 
 

upstream cluster1{server 10.0.0.4:80  weight=1 max_fails=3 fail_timeout=30s;server 10.0.0.5:80  weight=1 max_fsils=3 fsil_tomeout;check interval=3000 rise=2 fall=5 timeout=1000 type=http;check interval=3000 rise=2 fall=5 timeout=1000 type=http;check_http_send "HEAD /HTTP/1.0/r/n/r/n";check_http_expect_alive http_2xx http_3xx;
} server {listen 80;server_name Lb.oldboylinux.cn;error_log /var/log/nginx/lb-error.log notice;access_log /var/log/nginx/lb-access.log main;location / {proxy_pass http://lb_pools;proxy_set_header Host $host;proxy_set_header X-Forwarded-For $remote_addr;}
}location /1{proxy_pass http://cluster1;
}location /2{proxy_pass http://cluster2;
}location /status{check_status;access_log  off;allow 10.0.0.1;allow 10.0.0.0/24;deny all;
}}




最后访问Lb.oldboylinux.cn页面出来的是测试模块


 


web集群  nginx rewrite功能 
 

nginx重定向
url重定向又叫做url改写 


rewrite模块 

 
 

return指令 

我们在配置文件中加入reutrn 模块 

具体如下
 

server {listen 80;server_name rewrite.xm cn;  # 修正 server_nameroot /app/code/rewrite;location / {index index.html;try_files $uri $uri/ =404;  # 处理文件不存在的情况}location /admin/ {return 403;  # 禁止访问}
}


当我们做好域名解析以后 访问网站/admin/模块就会出现以下情形
 



域名间跳转 

 

server {listen 80;server_name rewrite.xm cn;  # 修正 server_nameroot /app/code/rewrite;# 对根路径的请求location / {index index.html;try_files $uri $uri/ =404;  # 处理文件不存在的情况}# 对/admin/路径的请求location /admin/ {return 403;  # 禁止访问}# 如果希望重定向某个具体路径,可以添加相应的 location 块location /redirect {return 301 http://www.baidu.com;  # 重定向到百度}
}


nginx   if判断 

一般放在 server,location 


if(条件){
满足条件执行的内容
}
 

set 自己创建或者修改nginx变量 

set $变量 值 

 

http {server {listen 80;server_name example.com;# 设置一个变量set $is_mobile "no";# 检查请求头中的User-Agent是否包含"Mobile"if ($http_user_agent ~* "Mobile") {set $is_mobile "yes";}location / {# 如果变量$is_mobile为"yes",则返回状态码403if ($is_mobile = "yes") {return 403;}# 否则,返回状态码200return 200;}}
}




rewrite模块 
 

 




域名跳转 

 

server {listen 80;server_name rewrite.oldboylinux.cn;# 这一行是实际执行的重写规则rewrite ^([^/]*)$ http://www.baidu.com$1;
}


版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com