Dynamic redirect error 500 based on url

42 views
Skip to first unread message

victorf...@ilhasoft.com.br

unread,
Sep 29, 2017, 10:03:15 AM9/29/17
to openresty-en
Hey guys, I have problem, any one can help me?

So my problems is that when my proxy pass return error 500 I want redirect to another server with same data params


worker_processes 1;
daemon off;
env REDIS_MASTER_ADDRESS;
env REDIS_MASTER_PORT;
env REDIS_MASTER_DB;
master_process off;
error_log  stderr  info;
events {

    worker_connections 1024;
}
http {

    server {

        listen 80;
       charset utf-8;
       location /bots {
           set $proxy_addr '';
           access_by_lua_file /home/config/routers/bots.lua; # it's will return a proxy pass value to $proxy_addr
           proxy_pass http://$proxy_addr;
       }
       location /train-bot {
           set $proxy_addr '';
           access_by_lua_file /home/config/routers/train_bot.lua; # it's will return a proxy pass value to $proxy_addr
           proxy_pass http://$proxy_addr;
       }
       error_page 500 502 503 504 /bots-redirect;
       location /bots-redirect {
           set $proxy_addr '';
           access_by_lua_file /home/config/routers/errors.lua;
           proxy_pass http://$proxy_addr;
       }

    }
}

So I want do some like this:

If my proxy pass to "/bots" fail I want redirect this failed request to another proxy pass

In this case my code redirect to corrent url "/bots-redirect" in another proxy pass, but without params.

How can I get/set this params to this request?

tokers

unread,
Sep 29, 2017, 11:29:14 PM9/29/17
to openresty-en
you can always get the uri params from the nginx variable $args, so maybe append this to your proxy_pass directive explicitly can solve your problem?
Reply all
Reply to author
Forward
0 new messages