Openrsty (nginx_lua_module) do es Proxy and back up ES data

Source: Internet
Author: User

#user nobody;worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log Info;pid logs/nginx.pid;events {worker_connections 1024;}        HTTP {upstream Master {server 10.1.1.100:9200;    Server 10.1.1.100:9200 backup; #备份库 keepalive 15;        } upstream Slave {#备份库 server 10.1.1.100:9200;    KeepAlive 15;        } server {server_name localhost 127.0.0.1 10.1.1.225;        Listen 8888;  Location/{content_by_lua_block {local function getFile (file_name) Local F                    = Assert (Io.open (file_name, ' R ')) Local string = F:read ("*all") F:close () Return string End Ngx.req.read_body () Ngx.log (NGX. ERR, ' $$$ '. Ngx.var.request_uri.       ' $$$ ') Local request_body = Ngx.req.get_body_data () if nil = = Request_body Then                 Local file_name = Ngx.req.get_body_file () if file_name then  Request_body = GetFile (file_name) end end local MASTER_RESP, Slave_resp local req_method_constant = ngx[' http_ ': Ngx.req.get_method ()] Local Arry = {m Ethod = req_method_constant, BODY = request_body} if req_method_constant = = Ngx. Http_post or Req_method_constant = = Ngx. Http_put or Req_method_constant = = Ngx.                        Http_delete then Master_resp, Slave_resp = ngx.location.capture_multi{                    {'/slave ': Ngx.var.request_uri, Arry}, {'/master ': Ngx.var.request_uri, Arry} } else Master_resp = ngx.location.capture_multi{{' /master '.                Ngx.var.request_uri, Arry}} end--[[using Master's response header--]] for k,v in pairs (master_resp.header) do Ngx.header[k] = V end Ngx.say (master_resp.body)}} Locati            On ~* ^/master {internal;            Rewrite ^/master (. *) $ $ break;        Proxy_pass Http://master;            } location ~* ^/slave {internal;            Log_subrequest on;            Rewrite ^/slave (. *) $ $ break;            Proxy_pass Http://slave;        Access_log Logs/upstream.log; }    }}

  

Openrsty (nginx_lua_module) do es Proxy and back up ES data

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.