Comments (5)
Hi @fabubacker ,
This is supported out of the box in the Enterprise edition: https://www.krakend.io/docs/enterprise/service-settings/virtual-hosts/ but not in the community.
You can make conditional requests with CEL in CE, but you should have multiple backends, not endpoints. You cannot create an endpoint twice.
You can also use Lua scripts and Go pugins to support this scenario, there are plenty of options
from krakend-ce.
Thanks @alombarte for the response. With CEL and multiple backends, how to differentiate the request between backends with two different domain names? Is it possible in community edition without any customization like Lua scripts and Go pugins? The apps we are looking to onboard in api gateway are simple ones so not looking to making it as complex with custom scripts.
from krakend-ce.
Hi @fabubacker ,
The following configuration does precisely what you want; it's functional (uses KrakenD itself as backend), so you get the point.
{
"version": 3,
"$schema": "https://www.krakend.io/schema/krakend.json",
"host": [
"http://localhost:8080"
],
"echo_endpoint": true,
"endpoints": [
{
"endpoint": "/all-domains",
"backend": [
{
"url_pattern": "/__echo/domain-A",
"allow": [
"req_uri"
],
"group": "A"
},
{
"url_pattern": "/__echo/domain-B",
"allow": [
"req_uri"
],
"group": "B"
}
]
},
{
"endpoint": "/one-domain",
"backend": [
{
"url_pattern": "/__echo/domain-A",
"allow": [
"req_uri"
],
"group": "A",
"extra_config": {
"validation/cel": [
{
"check_expr": "'a.com' in req_headers['X-Forwarded-Host']"
}
]
}
},
{
"url_pattern": "/__echo/domain-B",
"allow": [
"req_uri"
],
"group": "B",
"extra_config": {
"validation/cel": [
{
"check_expr": "'b.com' in req_headers['X-Forwarded-Host']"
}
]
}
}
]
}
]
}
Then try the following commands:
curl -H'Host: z.com' http://localhost:8080/all-domains
curl -H'Host: a.com' http://localhost:8080/one-domain
curl -H'Host: b.com' http://localhost:8080/one-domain
from krakend-ce.
Thanks @alombarte it is working but not fitting my scenario as I am using Krakend as proxy for the backends. Looks like no-op
cannot be used for endpoints with more than one backend.
from krakend-ce.
If you need no-op
then you must use a Lua script. This can give you an idea of how to do it:
https://www.krakend.io/docs/enterprise/backends/lambda/#canary-testing-of-lambda-functions
from krakend-ce.
Related Issues (20)
- Hot reloading not working - error parsing the configuration file, unexpected end of JSON input
- v2.5 change on propagate_claims won't allow us to upgrade HOT 1
- When returning error from request modifier from backend, skips the response aggregation step.
- Error responses' Content-Type is always returned as text/plain for the client HOT 1
- Redirect to custom URL HOT 2
- Use values in body sent to gateway and send them as header values to the service HOT 2
- [HELP] make build fails with error = untyped int constant as int value in assignment (overflows) HOT 3
- auth/validator need to be configured all end points HOT 2
- Error relocating grpc-gateway.so: unsupported relocation type 7 HOT 1
- Unable to handle query string with space character(%20) , getting error HOT 2
- Simultaneous loading of client and server plugins does not load the server one HOT 1
- KrakenD returns empty response for collection endpoint HOT 1
- Error #01: context canceled HOT 2
- Unable to get headers and statuscode using the examples HOT 1
- Create a queue in rabbitmq HOT 2
- Link to 'Docs' for Endpoint Rate Limit in Designer links to a page that no longer exists HOT 1
- Moving token from querystring to header before validate it HOT 2
- How to configure Krakend to support Upload File Endpoint HOT 2
- HEAD method is not supported HOT 1
- input-query-params working bad?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from krakend-ce.