$request_uri的使用

本地的elasticsearch服务,需要对访问链接进行rewrite。

upstream monitor_server {
    server IP:9200 max_fails=0 fail_timeout=10s;
}
server {
                listen                  80;
                server_name             proxy.test.net;
                rewrite_log             on;
                charset                 utf8;

                access_log  /home/bruce/log/nginx/proxy_test.access.log ;
                error_log  /home/bruce/log/nginx/proxy_test.error.log info;

                #location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|rar|swf|apk|html)$ {
                #        access_log      off;
                #        expires         30d;
                #        add_header Cache-Control public;
                #}

                if ($request_uri ~ '^/megacorp/([0-9])$'){
                    rewrite '^/megacorp/([0-9])$' http://proxy.test.net/megacorp/employee/$1 redirect;
                }

                location / {
                    include proxy_params;
                    proxy_redirect off;
                    proxy_pass  http://monitor_server;
                }
}

你可能感兴趣的:(nginx)