docs: update example of configurations

This commit is contained in:
Jonas Kaninda
2024-10-29 19:38:43 +01:00
parent 97c7e0940b
commit ebebb9cd5e
2 changed files with 56 additions and 34 deletions

View File

@@ -130,15 +130,15 @@ gateway:
disableDisplayRouteOnStart: false disableDisplayRouteOnStart: false
# interceptErrors intercepts backend errors based on defined the status codes # interceptErrors intercepts backend errors based on defined the status codes
interceptErrors: interceptErrors:
# - 405 - 405
# - 500 - 500
# - 400 # - 400
# Proxy Global HTTP Cors # Proxy Global HTTP Cors
cors: cors:
# Global routes cors for all routes # Global routes cors for all routes
origins: origins:
- http://localhost:8080
- https://example.com - https://example.com
- https://auth.example.com
# Global routes cors headers for all routes # Global routes cors headers for all routes
headers: headers:
Access-Control-Allow-Headers: 'Origin, Authorization, Accept, Content-Type, Access-Control-Allow-Headers, X-Client-Id, X-Session-Id' Access-Control-Allow-Headers: 'Origin, Authorization, Accept, Content-Type, Access-Control-Allow-Headers, X-Client-Id, X-Session-Id'
@@ -147,26 +147,27 @@ gateway:
##### Define routes ##### Define routes
routes: routes:
# Example of a route | 1 # Example of a route | 1
- name: Store - name: Public
# host Domain/host based request routing # host Domain/host based request routing
host: dev.example.com host: ""
path: /store path: /public
## Rewrite a request path ## Rewrite a request path
# e.g rewrite: /store to / # e.g rewrite: /store to /
rewrite: / rewrite: /healthz
destination: 'http://store-service:8080' destination: https://example.com
#DisableHeaderXForward Disable X-forwarded header. #DisableHeaderXForward Disable X-forwarded header.
# [X-Forwarded-Host, X-Forwarded-For, Host, Scheme ] # [X-Forwarded-Host, X-Forwarded-For, Host, Scheme ]
# It will not match the backend route, by default, it's disabled # It will not match the backend route, by default, it's disabled
disableHeaderXForward: false disableHeaderXForward: false
# Internal health check # Internal health check
healthCheck: /internal/health/ready healthCheck: '' #/internal/health/ready
# Route Cors, global cors will be overridden by route # Route Cors, global cors will be overridden by route
cors: cors:
# Route Origins Cors, global cors will be overridden by route # Route Origins Cors, global cors will be overridden by route
origins: origins:
- https://dev.example.com - https://dev.example.com
- http://localhost:3000 - http://localhost:3000
- https://example.com
# Route Cors headers, global cors will be overridden by route # Route Cors headers, global cors will be overridden by route
headers: headers:
Access-Control-Allow-Methods: 'GET' Access-Control-Allow-Methods: 'GET'
@@ -185,16 +186,25 @@ gateway:
## List of middleware name ## List of middleware name
middlewares: middlewares:
# path to protect # path to protect
- path: /user/account - path: /user
# Rules defines which specific middleware applies to a route path # Rules defines which specific middleware applies to a route path
rules: rules:
- auth - basic-auth
# path to protect # path to protect
- path: /cart - path: /path-example
# Rules defines which specific middleware applies to a route path # Rules defines which specific middleware applies to a route path
rules: rules:
- google-auth - jwtAuth
- auth # path to protect
- path: /admin
# Rules defines which specific middleware applies to a route path
rules:
- basic-auth
# path to protect
- path: /path-example
# Rules defines which specific middleware applies to a route path
rules:
- jwtAuth
- path: /history - path: /history
http: http:
url: http://security-service:8080/security/authUser url: http://security-service:8080/security/authUser
@@ -214,8 +224,8 @@ gateway:
blocklist: [] blocklist: []
middlewares: [] middlewares: []
# Example of a route | 3 # Example of a route | 3
- name: Notification - name: Basic auth
path: /notification path: /protected
rewrite: / rewrite: /
destination: 'http://notification-service:8080' destination: 'http://notification-service:8080'
healthCheck: healthCheck:
@@ -227,17 +237,18 @@ gateway:
middlewares: middlewares:
# Enable Basic auth authorization based # Enable Basic auth authorization based
- name: local-auth-basic - name: local-auth-basic
# Authentication types | jwtAuth, basicAuth, OAuth # Authentication types | jwtAuth, basicAuth, auth0
type: basicAuth type: basicAuth
rule: rule:
username: admin username: admin
password: admin password: admin
#Enables JWT authorization based on the result of a request and continues the request. #Enables JWT authorization based on the result of a request and continues the request.
- name: google-auth - name: google-auth
# Authentication types | jwtAuth, basicAuth, auth0 # Authentication types | jwtAuth, basicAuth, OAuth
# jwt authorization based on the result of backend's response and continue the request when the client is authorized # jwt authorization based on the result of backend's response and continue the request when the client is authorized
type: jwtAuth type: jwtAuth
rule: rule:
# This is an example URL
url: https://www.googleapis.com/auth/userinfo.email url: https://www.googleapis.com/auth/userinfo.email
# Required headers, if not present in the request, the proxy will return 403 # Required headers, if not present in the request, the proxy will return 403
requiredHeaders: requiredHeaders:

View File

@@ -20,15 +20,15 @@ gateway:
disableDisplayRouteOnStart: false disableDisplayRouteOnStart: false
# interceptErrors intercepts backend errors based on defined the status codes # interceptErrors intercepts backend errors based on defined the status codes
interceptErrors: interceptErrors:
# - 405 - 405
# - 500 - 500
# - 400 # - 400
# Proxy Global HTTP Cors # Proxy Global HTTP Cors
cors: cors:
# Global routes cors for all routes # Global routes cors for all routes
origins: origins:
- http://localhost:8080
- https://example.com - https://example.com
- https://auth.example.com
# Global routes cors headers for all routes # Global routes cors headers for all routes
headers: headers:
Access-Control-Allow-Headers: 'Origin, Authorization, Accept, Content-Type, Access-Control-Allow-Headers, X-Client-Id, X-Session-Id' Access-Control-Allow-Headers: 'Origin, Authorization, Accept, Content-Type, Access-Control-Allow-Headers, X-Client-Id, X-Session-Id'
@@ -37,26 +37,27 @@ gateway:
##### Define routes ##### Define routes
routes: routes:
# Example of a route | 1 # Example of a route | 1
- name: Store - name: Public
# host Domain/host based request routing # host Domain/host based request routing
host: dev.example.com host: ""
path: /store path: /public
## Rewrite a request path ## Rewrite a request path
# e.g rewrite: /store to / # e.g rewrite: /store to /
rewrite: / rewrite: /healthz
destination: 'http://store-service:8080' destination: https://example.com
#DisableHeaderXForward Disable X-forwarded header. #DisableHeaderXForward Disable X-forwarded header.
# [X-Forwarded-Host, X-Forwarded-For, Host, Scheme ] # [X-Forwarded-Host, X-Forwarded-For, Host, Scheme ]
# It will not match the backend route, by default, it's disabled # It will not match the backend route, by default, it's disabled
disableHeaderXForward: false disableHeaderXForward: false
# Internal health check # Internal health check
healthCheck: /internal/health/ready healthCheck: '' #/internal/health/ready
# Route Cors, global cors will be overridden by route # Route Cors, global cors will be overridden by route
cors: cors:
# Route Origins Cors, global cors will be overridden by route # Route Origins Cors, global cors will be overridden by route
origins: origins:
- https://dev.example.com - https://dev.example.com
- http://localhost:3000 - http://localhost:3000
- https://example.com
# Route Cors headers, global cors will be overridden by route # Route Cors headers, global cors will be overridden by route
headers: headers:
Access-Control-Allow-Methods: 'GET' Access-Control-Allow-Methods: 'GET'
@@ -75,16 +76,25 @@ gateway:
## List of middleware name ## List of middleware name
middlewares: middlewares:
# path to protect # path to protect
- path: /user/account - path: /user
# Rules defines which specific middleware applies to a route path # Rules defines which specific middleware applies to a route path
rules: rules:
- auth - basic-auth
# path to protect # path to protect
- path: /cart - path: /path-example
# Rules defines which specific middleware applies to a route path # Rules defines which specific middleware applies to a route path
rules: rules:
- google-auth - jwtAuth
- auth # path to protect
- path: /admin
# Rules defines which specific middleware applies to a route path
rules:
- basic-auth
# path to protect
- path: /path-example
# Rules defines which specific middleware applies to a route path
rules:
- jwtAuth
- path: /history - path: /history
http: http:
url: http://security-service:8080/security/authUser url: http://security-service:8080/security/authUser
@@ -104,8 +114,8 @@ gateway:
blocklist: [] blocklist: []
middlewares: [] middlewares: []
# Example of a route | 3 # Example of a route | 3
- name: Notification - name: Basic auth
path: /notification path: /protected
rewrite: / rewrite: /
destination: 'http://notification-service:8080' destination: 'http://notification-service:8080'
healthCheck: healthCheck:
@@ -128,6 +138,7 @@ middlewares:
# jwt authorization based on the result of backend's response and continue the request when the client is authorized # jwt authorization based on the result of backend's response and continue the request when the client is authorized
type: jwtAuth type: jwtAuth
rule: rule:
# This is an example URL
url: https://www.googleapis.com/auth/userinfo.email url: https://www.googleapis.com/auth/userinfo.email
# Required headers, if not present in the request, the proxy will return 403 # Required headers, if not present in the request, the proxy will return 403
requiredHeaders: requiredHeaders: