-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Complex Routing #2324
Comments
yes, you can do that. Longer uris are matched before shorted ones. The down side is that the website will consist of 3 apis in Kong terminology. You might also consider exposing a different path on the outside, and internally forward to the proper ones. eg. |
@Vad1mo in your desired configuration, will Kong be proxying requests for your website content (eg. images, HTML, CSS, JS, etc)? |
Thank you for the clarification.
Yes. The situation is the following, there is a Admin Dashboard. In my simplified example I call it "Website". In reality that the Web application serves HTML,JS Content and also a REST API. I know that Kong, wasn't designed for this, but I guess it isn't a problem even if the gateway is also proxying to a website. Or Are there any other solutions without to many applications involved.
Unfortunately It isn't possible to expose a different path to the outside as @Tieske suggested. All clients out there expect a v1 or v2 path and there are many clients. What I could do is to change the web application and its api path. |
Nginx on the other hand, is definitely built to handle such use-cases. I would suggest using a custom Nginx configuration with a location block for serving your website, and one for serving Kong. Your website location block can definitely use settings that are more appropriate for such reverse-proxying of assets files, thus giving you the best of both worlds: a Kong instance able to proxy your APIs and your website in an efficient manner. |
Before closing the the issue. One final question for clarificatigon
Am I right that you personally would recommend to create a cascading proxy hierarchy, where a second nginx instance is located in front of kong and is serving the static website and otherwise forwarding to kong. Doesn't it make the whole setup overly complex as you need to take care of load balancing on two instances and. Or do you mean (if that it is possible/recommended?) to provide kong with an additional custom nginx.conf with location and tuning for the static website/content? I am asking the reassurance question to better understand the best/common practice approaches when working with kong. |
This is what I mean. The goal is indeed not to have to maintain a second Nginx instance, and take full advantage of the fact that Kong is built on top of Nginx and is a drop-in replacement (or will be). We thus kill two birds with the same stone 😉 |
🥇 Drop-in replacement for nginx Thank you very much for clarification. |
Related documentation added here. |
Summary
I wonder if I could do some more complex routing. My scenario works nginx but not with API Gateways known to me.
I have two services behind one Url (app.company.com). Lets call one service "Website" and the other "API Service"
The "API Service" should receiver traffic for
app.company.com/v2/*
The "Website" should receive traffic for
app.company.com/*
app.company.com/v2/token
app.company.com/v2/webhook
So the tricky part here is that
/v2/token
and/v2/webhook
should go to "Website" instead to service.In nginx I have to create 4 locations to make this work, it does not work with only 2 locations and regex magic.
Additional Details & Logs
If found the PR #1970 which explains the router but does not answer my question.
The text was updated successfully, but these errors were encountered: