How Services and Routes Work Together
A Service stores the address and connection behavior of the API that will process a request. A Route stores the public matching rules used to decide whether an incoming request belongs to that Service.
Create the Service first, then attach one or more Routes. Multiple Routes can point to the same Service when different hosts, paths, methods or policies must reach the same API.
Client request → Route match → Service connection → API response. A request must satisfy the configured Route conditions before it can reach the Service.
Before You Configure an API
- Prepare the protocol, host or IP address, port and optional base path of the target API.
- Decide which public hosts, paths and HTTP methods clients will use.
- Choose a unique naming convention for Services and Routes, such as team-api-environment.
- Prepare Certificate and CA Certificate IDs before enabling client-certificate authentication or upstream TLS verification.
Create a Service
- Open Services and select Create Service.
- Enter a unique Service Name. The name must contain at least three characters and can use letters, numbers, hyphens and underscores.
- Choose Full URL to let Apiruler derive the protocol, host, port and path, or choose Manual Configuration to enter those values separately.
- Select a folder and add comma-separated tags when you need to group or filter the Service.
- Keep Service Enabled on to make the configuration active after creation.
- Review Advanced Configuration when retry, timeout or TLS behavior must differ from the defaults, then select Create.
| Field | Requirement | Description | Example |
|---|---|---|---|
| Service Name | Required | Unique name with at least three supported characters. | orders-api |
| Full URL | Required in URL mode | Complete HTTP or HTTPS target. Apiruler derives its connection fields. | https://backend.example.com/v1 |
| Protocol | Required in manual mode | HTTP, HTTPS, gRPC, gRPCs, TCP or TLS. | HTTPS |
| Host | Required in manual mode | Target hostname, IP address or Load Balancer name. | backend.example.com |
| Port | Required in manual mode | Target port from 1 through 65535. | 443 |
| Path | Optional | Base path appended to requests sent to the target API. | /v1 |
| Folder | Optional | Logical group used to organize Services in the interface. | Production APIs |
| Tags | Optional | Comma-separated labels used for filtering and organization. | production, orders |
When a Full URL does not contain a port, HTTPS uses 443 and HTTP uses 80. A root URL path is stored without an additional Service path.
The new Service appears in the Services list with its protocol, host, port and enabled status.
Service Advanced Configuration
| Field | Default | Allowed value | Technical effect |
|---|---|---|---|
| Retries | 5 | 0–100 | Maximum retry count used when a connection attempt fails. |
| Connect Timeout | 60000 ms | At least 1 ms | Maximum time allowed to establish the target connection. |
| Write Timeout | 60000 ms | At least 1 ms | Maximum idle time allowed while sending the request. |
| Read Timeout | 60000 ms | At least 1 ms | Maximum idle time allowed while waiting for response data. |
| Client Certificate ID | Empty | Existing Certificate ID | Certificate presented when a client certificate is required by the target API. |
| CA Certificates | Empty | Comma-separated CA Certificate IDs | Trust records used to verify the target TLS certificate. |
| TLS Verification | Off | On or off | Controls whether the target TLS certificate is verified. |
Enable TLS Verification only after the required CA Certificate records are available and their IDs are assigned to the Service.
Create a Route
- Open Routes and select Create Route.
- Enter a Route Name with at least two characters. Letters, numbers, dots, hyphens and underscores are accepted.
- Select the Service that will receive matching requests. The Service assignment is required during creation and cannot be changed from the edit form.
- Select HTTP, HTTPS or both. If neither option remains selected, the form submits both HTTP and HTTPS.
- Enter one or more matching conditions in Paths, Hosts, Methods, Headers or SNIs.
- Review the advanced path, redirect and buffering options, then select Create.
Use at least one meaningful Paths, Hosts, Methods, Headers or SNIs condition. A Route with overly broad conditions can receive traffic intended for another API.
Route Matching Fields
| Field | Input format | Matching behavior | Example |
|---|---|---|---|
| Paths | Comma-separated paths | Matches the request URL path. | /orders, /v1/orders |
| Hosts | Comma-separated hostnames | Matches the incoming Host value. | api.example.com |
| Methods | Comma-separated HTTP methods | Limits the Route to the listed methods. | GET, POST |
| Headers | JSON object with arrays of values | Matches requests containing the configured header values. | {"x-client-type":["mobile","web"]} |
| SNIs | Comma-separated names | Matches the TLS server name used by the client. | api.example.com, *.example.com |
| Protocols | HTTP and/or HTTPS | Limits the transport protocols that can match. | HTTP, HTTPS |
{"x-api-version":["v1"],"x-client-type":["mobile","web"]}Advanced Route Behavior
| Field | Default | Description |
|---|---|---|
| Path Handling | v0 | Controls how the Route path and Service path are combined. |
| HTTPS Redirect Status Code | Empty | Optional integer from 301 through 599 used for protocol redirection behavior. |
| Regex Priority | 0 | Priority used when multiple regular-expression paths can match. |
| Strip Path | On | Removes the matched Route path before the request is sent to the Service. |
| Preserve Host | Off | Keeps the incoming Host header instead of using the Service host. |
| Request Buffering | On | Buffers the client request before forwarding when supported. |
| Response Buffering | On | Buffers the Service response before returning it when supported. |
Verify Service and Route Configuration
- Open the Service detail page and confirm the target protocol, host, port, path and enabled status.
- Open the Route detail page and confirm that it points to the intended Service.
- Send one request that satisfies the Route conditions and confirm that the expected API response is returned.
- Send a second request with a non-matching host, path or method and confirm that the Route is not selected.
- Check Monitoring and Logging for request count, latency and error evidence after test traffic is sent.
Service and Route Troubleshooting
| Problem | Likely cause | What to do |
|---|---|---|
| The Service cannot be created. | The name, URL, host or port does not satisfy form validation. | Check the supported name characters, use a complete URL, or enter a port from 1 through 65535. |
| A matching request does not reach the API. | The Route conditions do not match or the Service target is unreachable. | Compare the request host, path, method and protocol with the Route, then verify the Service address. |
| The API receives an unexpected path. | Strip Path, Path Handling or the Service base path is not configured as intended. | Review the three path settings together and retest with a known request URL. |
| TLS verification fails. | The target certificate is untrusted, expired or does not match the configured host. | Check the CA Certificate IDs, target hostname and certificate validity before retrying. |
| A request reaches the wrong Route. | Two Routes have overlapping matching rules. | Make the host, path, method or regex priority more specific. |