在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
content_by_luaserver { listen 80; server_name lua.luckybing.top; location / { default_type 'text/plain'; content_by_lua ' if ngx.var.remote_addr=="203.100.83.125" then ngx.say("hello,from yunxiao") else ngx.say("hello,from other") end'; } } rewrite_by_luaserver { listen 80; server_name lua.luckybing.top; location / { rewrite_by_lua ' if ngx.var.remote_addr=="203.100.83.125" then return ngx.redirect("http://www.luckybing.top", 302) else return ngx.redirect("http://chat.luckybing.top", 302) end'; } } access_by_luaserver { listen 80; server_name lua.luckybing.top; location @client{ proxy_pass http://www.baidu.com; } location / { access_by_lua ' if ngx.var.remote_addr=="203.100.83.125" then ngx.exit(ngx.HTTP_FORBIDDEN) else ngx.exec("@client") end'; } } rewrite_by_luaserver { listen 80; server_name lua.luckybing.top; location @client{ proxy_pass http://47.95.222.240:3000; } location @client2{ proxy_pass http://47.95.222.240:4000; } location / { default_type 'text/html'; #ngx.var.remote_addr rewrite_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=="203.100.83.125" then ngx.exec("@client2") else ngx.exec("@client") end'; } } lua-nginx 负载均衡 upstream wxqy { ip_hash; server 127.0.0.1:4000; server 127.0.0.1:4001; } server { listen 8091; server_name wxqy.iyunxiao.net; server_tokens off; access_log off; location @client{ proxy_pass http://wxqy; } location @client2{ proxy_pass http://127.0.0.1:4002; } location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header REMOTE-HOST $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; #proxy_pass http://wxqy; default_type 'text/plain'; rewrite_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=="172.31.0.2" then ngx.exec("@client2") else ngx.exec("@client") end'; } }
|
请发表评论