We are using kong as a automatic load balance proxy. We were trying using admin API https://getkong.org/docs/0.13.x/loadbalancing/ https://getkong.org/docs/0.13.x/admin-api/ to configure kong to server web application backend (like tomcat and java application).
But now we are facing a problem , that can be fix by nginx http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_redirect , but we can't find a same parameter to configure kong.
Is that feature needed in kong?
I'm about to try https://github.com/Kong/kong/issues/839 to change nginx configuration
By Reading https://github.com/Kong/kong/issues/839 ,Knowledge that I can configure nginx to fix this bug,read this to change nginx configuration:
http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_redirect
By reading https://getkong.org/docs/0.13.x/configuration/#custom-nginx-configuration knowledeg that I can chage kong-nginx.conf。
by find /|grep nignx, I find this /usr/local/kong/nginx-kong.conf confirguration file,and then I find this file was generated by /usr/local/share/lua/5.1/kong/templates/nginx_kong.lua 。
Finally I change this file /usr/local/share/lua/5.1/kong/templates/nginx_kong.lua ,at the server listening 8000 port , at the location / append this proxy_redirect ~^(http://[^:]+):\d+(/.+)$ $2;
Restart kong, it works。
I tested the redirect 302 like this
Location: http://127.0.0.1:8000/iPlatAPM/login.jsp
before:
Location: http://10.70.xx.xx:8090/iPlatAPM/login.jsp
The probelm fixed。
Most helpful comment
By Reading https://github.com/Kong/kong/issues/839 ,Knowledge that I can configure nginx to fix this bug,read this to change nginx configuration:
http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_redirect
By reading https://getkong.org/docs/0.13.x/configuration/#custom-nginx-configuration knowledeg that I can chage kong-nginx.conf。
by
find /|grep nignx, I find this/usr/local/kong/nginx-kong.confconfirguration file,and then I find this file was generated by/usr/local/share/lua/5.1/kong/templates/nginx_kong.lua。Finally I change this file
/usr/local/share/lua/5.1/kong/templates/nginx_kong.lua,at the server listening 8000 port , at thelocation /append thisproxy_redirect ~^(http://[^:]+):\d+(/.+)$ $2;Restart kong, it works。
I tested the redirect 302 like this
Location: http://127.0.0.1:8000/iPlatAPM/login.jspbefore:
Location: http://10.70.xx.xx:8090/iPlatAPM/login.jspThe probelm fixed。