编程技术分享平台

网站首页 > 技术教程 正文

nginx+lua灰度发布(nginx lua 灰度发布)

xnh888 2024-09-08 10:57:14 技术教程 25 ℃ 0 评论

upstream www.test.cn {

server 192.168.1.100:9000;

server 192.168.1.100:9000;

}

upstream www.test.cn_huidu {

server 192.168.1.100:9000;

server 192.168.1.100:9000;

}

server {

listen 80;

server_name www.test.cn;

charset utf-8;

location ~ ^/webticket/WEB-INF/{

deny all;

}

#O

location / {

content_by_lua '

myIP = ngx.req.get_headers()["X-Real-IP"]

if myIP == nil then

myIP = ngx.req.get_headers()["x_forwarded_for"]

end

if myIP == nil then

myIP = ngx.var.remote_addr

end

if myIP == "111.222.1.100" then

ngx.exec("@www.test.cn_huidu")

else

ngx.exec("@www.test.cn")

end

';

}

#A

location @www.test.cn{

proxy_pass http://www.test.cn;

proxy_connect_timeout 60s;

proxy_read_timeout 5400s;

proxy_send_timeout 5400s;

proxy_redirect off;

proxy_set_header Host $host;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

index index.html index.htm index.jsp;

}

#B

location @www.test.cn_huidu{

proxy_pass http://www.test.cn_huidu;

proxy_connect_timeout 60s;

proxy_read_timeout 5400s;

proxy_send_timeout 5400s;

proxy_redirect off;

proxy_set_header Host $host;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

index index.html index.htm index.jsp;

}

error_page 500 502 503 504 /50x.html;

location = /50x.html {

root html;

}

}

各项注释说明:

https://www.toutiao.com/i6728550730573021703/

欢迎关注:悬钟Mr

https://www.toutiao.com/c/user/5844231468/#mid=1634198915259405

Tags:

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表