Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Being able to customize the upstream proxy errors #972

Closed
subnetmarco opened this issue Feb 9, 2016 · 16 comments
Closed

Being able to customize the upstream proxy errors #972

subnetmarco opened this issue Feb 9, 2016 · 16 comments
Labels
task/feature Requests for new features in Kong

Comments

@subnetmarco
Copy link
Member

Being able to customize the upstream error responses being returned by proxy_pass, by allowing to override the current templates.

The user would need to provide their own templates for all the response formats that we support.

@subnetmarco
Copy link
Member Author

Also the default 404 message when an API is not found could be customized.

@adamlc
Copy link

adamlc commented Sep 2, 2016

This would make sense, I'm just starting to use Kong and really surprised to not see this functionality at all!

@giorgiosironi
Copy link

I was trying to work around this with:

        error_page 403 /4xx.html;
        location = /4xx.html {
            root /usr/local/openresty/nginx/html;
            internal;
        }

but it seems to have no effect.

@giorgiosironi
Copy link

The error I am trying to customize is the 403 coming from the key-auth plugin:
https://github.com/Mashape/kong/blob/master/kong/plugins/key-auth/handler.lua#L80
However, after analysis I see there should be no difference between an upstream error and a ngx.exit() one, which is what this plugin is using through the responses module.

@giorgiosironi
Copy link

giorgiosironi commented Sep 26, 2016

For anyone trying to do the same: I needed to add:

 proxy_intercept_errors on;

to the Nginx configuration for upstream errors to be passed to error_page directives.

Instead, 40x produced by a plugin (like key-auth) still are not intercepted (they're not coming from a proxy).

@giorgiosironi
Copy link

(Possibly) traced the problem to the lua module, asking there: openresty/lua-nginx-module#875

@arno-di-loreto
Copy link

@thefosk Is there some news about this feature?
I just started playing with Kong, it's really a great API gateway (kudos for everybody involved) but having these messages that do not comply to the format of the exposed API is really annoying, it breaks the API consistency.

@subnetmarco
Copy link
Member Author

@arno-di-loreto we want to introduce this capability but currently we have other priorities. The only way today is to fork the plugins and change the message manually - but we want to provide an easier way.

@mwaaas
Copy link

mwaaas commented May 29, 2017

Hey @thefosk @Tieske @thibaultcha
I tried using Kong and its a really awesome project for api-gateway, For our case this feature is really important, would like to contribute to this feature, please guide me on how to do it.

@tetebueno
Copy link

Hi, any news about this? If not, anyone would be able to point out a fork with some progress about it?
Cheers.

@mwaaas
Copy link

mwaaas commented Oct 24, 2017

@tetebueno there is a hack that we did. Overriding the kong.tools.response file.

@takearun
Copy link

takearun commented Nov 27, 2017

Hi @mwaaas , we are after this feature too, can you please tell us how you changed kong.tools.response?

@srilathatata
Copy link

Hi, anyone got a working sample for achieving this, customising the error message? appreciate any help thanks

@mwaaas
Copy link

mwaaas commented Dec 23, 2017

@takearun created a folder called kong/tools and added response file to the directory, then added my directory to the lua path, in that way when Kong tries to import kong.tools.response it would import my file.

Let me know if that helps.

@matti
Copy link

matti commented Feb 10, 2018

#3192

@spmsupun
Copy link

spmsupun commented Jun 7, 2020

Is this implemented yet ?

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
task/feature Requests for new features in Kong
Projects
None yet
Development

No branches or pull requests