All services deployed by Space Cloud can be accessed only from within the cluster. Its as if, they do not exist to the outside world.
Sometimes you might want to expose certain services or endpoints to the external world. This is especially true when you are hosting your frontend from within Space Cloud. To do this, we need to set up some rules in the
The recommended way to expose your endpoints is by using the GraphQL API for enhanced security and flexibility
Each incoming request is routed to one of the specified target services. A target service is selected randomly based on the weight assigned to it.
Routing rules can be applied based on the
URL of the incoming request. You can use either one or a combination of these to set up your routing rules.
By default, each security rule matches the incoming request irrespective of their host. To match requests from specific hosts only, check the
Allow traffic with specified hosts only option.
This allows you to insert an array of hosts you want the rule to match in the
Allowed hosts. The rule matches if any one of the
Allowed hosts matches with the host of the incoming request.
You can uncheck the
Allow traffic with specified hosts only option to match requests irrespective of the host.
By default, each security rule matches the incoming request irrespective of their method. To match requests from specific methods only, check the
Allow traffic with specified methods only option.
This allows you to select multiple methods for which you want the rule to match in the
Allowed methods. The rule matches if any one of the
Allowed methods matches with the method of the incoming request.
You can uncheck the
Allow traffic with specified methods only option to match requests irrespective of the method.
Url based matching consists of 3 parts -
URL / prefix and
match type option configures the URL matching scheme used. There can be two possible values:
URLto match with the prefix of the request’s URL.
URLmatches the request’s URL exactly.
rewrite is used to overwrite the prefix of the URL when enabled.
Let’s say we want to route all the incoming requests matching the following criteria:
between two of our services with equal probability. And let’s say we also want to replace the
/v1/foo in the incoming requests with
/foo before forwarding the requests to our services. Here’s how you can specify a routing rule in Space Cloud to achieve this:
|Route Matching Type||Prefix||Rewrite||Allowed hosts||Allowed methods|
URLonly of the incoming request.