Proxy with processing

71 views
Skip to first unread message

Vladimir K

unread,
Jul 9, 2017, 1:17:38 PM7/9/17
to openresty-en
It is my problem:

I need functions:
1) change source url (delete exactly params)
2) redirect to other host
3) get request and response for save to logs

my proxy listening  SOURCE_HOST:PORT

I get request like this SOURCE_HOST:PORT/path/path/variable?param_for_delete=345&param_must_be=356453
need redirect to NEW_HOST:PORT/path/path/variable?param_must_be=356453

my solution at this moment:

listen       PORT;
    server_name  name;
    location / {

        access_by_lua_block{

            ngx.req.read_body()
        
            local args = ngx.req.get_uri_args()
          
            args.param_for_delete = nil
            
            ngx.req.set_uri_args(args)
           
        }
            proxy_pass NEW_HOST:PORT;
    }

But I have wrong request NEW_HOST:PORT/path/path/variable?param_for_delete=345&param_must_be=356453

what am I doing wrong?

Ollie Ready

unread,
Aug 10, 2017, 2:21:58 PM8/10/17
to openresty-en
Look into proxy_redirect in addition to your proxy_pass config.

-Ollie
Reply all
Reply to author
Forward
0 new messages