Docs: update configuration and deployment

This commit is contained in:
Jonas Kaninda
2024-11-10 17:47:05 +01:00
parent 00702e138b
commit b2ae3cf0a5
6 changed files with 184 additions and 139 deletions

View File

@@ -44,6 +44,8 @@ It's designed to be straightforward and efficient, offering features, like:
- Custom Headers - Custom Headers
- Backend Errors interceptor - Backend Errors interceptor
- Logging - Logging
- Metrics
- Supports Load Balancing, round-robin algorithm
- Support TLS - Support TLS
- Block common exploits middleware - Block common exploits middleware
- Patterns to detect SQL injection attempts - Patterns to detect SQL injection attempts
@@ -58,11 +60,8 @@ It's designed to be straightforward and efficient, offering features, like:
- Limit HTTP methods allowed for a particular route. - Limit HTTP methods allowed for a particular route.
### Todo: ### Todo:
- [x] Support Load Balancing, round-robin algorithm
- [ ] Load Balancing Healthcheck, disable unavailable servers - [ ] Load Balancing Healthcheck, disable unavailable servers
- [ ] Blocklist IP address middleware - [ ] Blocklist IP address middleware
- [ ] Tracing
- [ ] Metrics
- [ ] Distributed Rate Limiting for In-Memory client IP based across multiple instances using Redis - [ ] Distributed Rate Limiting for In-Memory client IP based across multiple instances using Redis
---- ----

View File

@@ -21,6 +21,14 @@ docker run --rm --name goma-gateway \
-v "${PWD}/config:/etc/goma/" \ -v "${PWD}/config:/etc/goma/" \
jkaninda/goma-gateway config init --output /etc/goma/config.yml jkaninda/goma-gateway config init --output /etc/goma/config.yml
``` ```
## 2. Check configuration
```shell
docker run --rm --name goma-gateway \
-v "${PWD}/config:/etc/goma/" \
-p 8080:8080 \
jkaninda/goma-gateway config config check --config /etc/goma/config.yml
```
### 3. Start server with a custom config ### 3. Start server with a custom config
```shell ```shell

View File

@@ -10,6 +10,20 @@ nav_order: 5
Goma comes with routes healthcheck, that can be enabled and disabled. Goma comes with routes healthcheck, that can be enabled and disabled.
```yaml
version: 1.0
gateway:
routes:
- path: /cart
name: example route
rewrite: /
methods: []
healthCheck:
path: "/health/live"
interval: 30 # in Seconds
timeout: 10 # in Seconds
healthyStatuses: [200,404] # Healthy statuses
```
- Goma Gateway healthcheck: `/health/live` - Goma Gateway healthcheck: `/health/live`
- Routes health check: `health/routes` - Routes health check: `health/routes`

View File

@@ -8,5 +8,30 @@ nav_order: 4
# Load Balancing # Load Balancing
Goma Gateway supports rund robim load blancing
```yaml
version: 1.0
gateway:
routes:
- path: /
name: example route
hosts:
- example.com
- example.localhost
rewrite: /
methods: []
healthCheck:
path: "/"
interval: 0
timeout: 0
healthyStatuses: [200,404]
## destination: will be override by backends
destination: ""
backends:
- https://example.com
- https://example2.com
- https://example4.com
cors:
```

View File

@@ -0,0 +1,21 @@
---
title: Monitoring
layout: default
parent: Quickstart
nav_order: 6
---
# Monitoring
Goma collects and exports metrics
To enable metrics, you need to set `enableMetrics` to `true` and the metrics are available at `/metrics`
```yaml
version: 1.0
gateway:
enableMetrics: true
...
```

View File

@@ -10,164 +10,142 @@ nav_order: 2
The Route allows you to match on HTTP traffic and direct it to the backend. The Route allows you to match on HTTP traffic and direct it to the backend.
### Example of a route ### Simple route
```yaml ```yaml
version: 1.0 version: 1.0
gateway: gateway:
...
routes: routes:
- name: Example - name: Example
path: /store/cart path: /store/cart
rewrite: /cart rewrite: /cart
destination: http://cart-service:8080 destination: http://cart-service:8080
methods: [POST, PUT, GET] cors: {}
healthCheck: '' ```
### Route with limited HTTP methods
The proxy will allow all HTTP methods if there's no defined method.
Example of route with limited HTTP methods allowed for a particular route.
```yaml
version: 1.0
gateway:
...
routes:
- name: Example
path: /store/cart
rewrite: /cart
destination: http://cart-service:8080
methods: [PATCH, GET]
cors: {} cors: {}
middlewares: middlewares:
- api-forbidden-paths - api-forbidden-paths
- jwt-auth - jwt-auth
``` ```
### Full example of routes and middlewares ### Route with healthcheck
Example of route with backend health check.
```yaml ```yaml
# Goma Gateway configurations version: 1.0
gateway: gateway:
# Proxy write timeout ...
writeTimeout: 15
# Proxy read timeout
readTimeout: 15
# Proxy idle timeout
idleTimeout: 60
## SSL Certificate file
sslCertFile: '' #cert.pem
## SSL Private Key file
sslKeyFile: ''#key.pem
# Proxy rate limit, it's In-Memory IP based
rateLimit: 0
accessLog: "/dev/Stdout"
errorLog: "/dev/stderr"
## Enable, disable routes health check
disableHealthCheckStatus: false
## Returns backend route healthcheck errors
disableRouteHealthCheckError: false
# Disable display routes on start
disableDisplayRouteOnStart: false
# disableKeepAlive allows enabling and disabling KeepALive server
disableKeepAlive: false
# interceptErrors intercepts backend errors based on defined the status codes
interceptErrors:
- 405
- 500
# - 400
# Proxy Global HTTP Cors
cors:
# Global routes cors for all routes
origins:
- http://localhost:8080
- https://example.com
# Global routes cors headers for all routes
headers:
Access-Control-Allow-Headers: 'Origin, Authorization, Accept, Content-Type, Access-Control-Allow-Headers, X-Client-Id, X-Session-Id'
Access-Control-Allow-Credentials: 'true'
Access-Control-Max-Age: 1728000
##### Define routes
routes: routes:
# Example of a route | 1 - name: Example
- name: Public path: /store/cart
# host Domain/host based request routing rewrite: /cart
host: "" # Host is optional destination: http://cart-service:8080
path: /public methods: [PATCH, GET]
## Rewrite a request path
# e.g rewrite: /store to /
rewrite: /
destination: https://example.com
methods: [GET]
#DisableHeaderXForward Disable X-forwarded header.
# [X-Forwarded-Host, X-Forwarded-For, Host, Scheme ]
# It will not match the backend route, by default, it's disabled
disableHeaderXForward: false
# Internal health check
healthCheck: '' #/internal/health/ready
# Route Cors, global cors will be overridden by route
cors:
# Route Origins Cors, route will override global cors origins
origins:
- https://dev.example.com
- http://localhost:3000
- https://example.com
# Route Cors headers, route will override global cors headers
headers:
Access-Control-Allow-Methods: 'GET'
Access-Control-Allow-Headers: 'Origin, Authorization, Accept, Content-Type, Access-Control-Allow-Headers, X-Client-Id, X-Session-Id'
Access-Control-Allow-Credentials: 'true'
Access-Control-Max-Age: 1728000
##### Apply middlewares to the route
## The name must be unique
## List of middleware name
middlewares:
- api-forbidden-paths
# Example of a route | 2
- name: Basic auth
path: /protected
rewrite: /
destination: https://example.com
healthCheck: healthCheck:
path: "/health/live"
interval: 0
timeout: 0
healthyStatuses: [200,404]
cors: {} cors: {}
```
### Route with middleware
Example of route with backend health check.
```yaml
version: 1.0
gateway:
...
routes:
- name: Example
path: /store/cart
rewrite: /cart
destination: http://cart-service:8080
methods: []
healthCheck:
path: "/health/live"
interval: 0
timeout: 0
healthyStatuses: [200,404]
cors: {}
## Middleware
middlewares: middlewares:
- api-forbidden-paths - api-forbidden-paths
- basic-auth - jwt-auth
```
#Defines proxy middlewares ### Route with backend errors interceptor
# middleware name must be unique
middlewares: Example of route with backend errors interceptor.
# Enable Basic auth authorization based
- name: basic-auth ```yaml
# Authentication types | jwt, basic, OAuth version: 1.0
type: basic gateway:
paths: ...
- /user routes:
- /admin - name: Example
- /account path: /store/cart
rule: rewrite: /cart
username: admin destination: http://cart-service:8080
password: admin methods: []
#Enables JWT authorization based on the result of a request and continues the request. healthCheck:
- name: google-auth path: "/health/live"
# Authentication types | jwt, basic, OAuth interval: 0
# jwt authorization based on the result of backend's response and continue the request when the client is authorized timeout: 0
type: jwt healthyStatuses: [200,404]
# Paths to protect interceptErrors: [403,500]
paths: blockCommonExploits: false
- /protected-access cors: {}
- /example-of-jwt ## Middleware
#- /* or wildcard path middlewares:
rule: - api-forbidden-paths
# This is an example URL - jwt-auth
url: https://www.googleapis.com/auth/userinfo.email ```
# Required headers, if not present in the request, the proxy will return 403 ### Route with enabled load balancing
requiredHeaders:
- Authorization Example of route with load balancing enabled.
# You can also get headers from the authentication request result and inject them into the next request header or params.
# In case you want to get headers from the authentication service and inject them into the next request headers. ```yaml
# Set the request variable to the given value after the authorization request completes. version: 1.0
# In case you want to get headers from the authentication service and inject them into the next request headers. gateway:
# Key is authentication request response header Key. Value is the next Request header Key. ...
headers: routes:
userId: Auth-UserId - name: Example
userCountryId: Auth-UserCountryId path: /store/cart
# In case you want to get headers from the Authentication service and inject them to the next request params. rewrite: /cart
#Key is authentication request response header Key. Value is the next Request parameter Key. ## destination: will be override by backends
params: destination: ""
userCountryId: countryId backends:
# The server will return 403 - https://example.com
- name: api-forbidden-paths - https://example2.com
type: access - https://example4.com
## prevents access paths methods: []
paths: healthCheck:
- /swagger-ui/* path: "/health/live"
- /v2/swagger-ui/* interval: 0
- /api-docs/* timeout: 0
- /internal/* healthyStatuses: [200,404]
- /actuator/* interceptErrors: [403,500]
blockCommonExploits: false
cors: {}
## Middleware
middlewares:
- api-forbidden-paths
- jwt-auth
``` ```