feat(treafik): add RealIP and addPrefix middleware (#3884)

* fix typo

* feat(treafik): add RealIP middleware

* move middlewares to includes

* bump minor

* remove pilot reference

* lint

* lint

* fix typo in workflow

* add script to update traefikMiddlewares

* add empty space

* realIP empty array

* add addprefix middleware
This commit is contained in:
Stavros Kois
2022-09-25 11:14:39 +02:00
committed by GitHub
parent 46737b4916
commit ccf932740b
23 changed files with 650 additions and 374 deletions
+1 -1
View File
@@ -23,7 +23,7 @@ sources:
- https://github.com/traefik/traefik-helm-chart
- https://traefik.io/
type: application
version: 13.3.11
version: 13.4.0
annotations:
truecharts.org/catagories: |
- network
@@ -22,7 +22,7 @@ Edit your existing traefik install (or install fresh if you don't have it instal
This will capture `https://remote.domain.com` or `https://remote.domain.com/`
and redirect it to `https://remote.domain.com/guacamole`
## Applying the theme to the app
## Applying the regex redirect middleware to the app
Edit your existing _App_, in this example we will use `guacamole-client`.
+11 -360
View File
@@ -176,366 +176,17 @@ questions:
additional_attrs: true
type: dict
attrs:
- variable: basicAuth
label: "basicAuth"
schema:
type: list
default: []
items:
- variable: basicAuthEntry
label: ""
schema:
additional_attrs: true
type: dict
attrs:
- variable: name
label: "Name"
schema:
type: string
required: true
default: ""
- variable: users
label: "Users"
schema:
type: list
default: []
items:
- variable: usersEntry
label: ""
schema:
additional_attrs: true
type: dict
attrs:
- variable: username
label: "Username"
schema:
type: string
required: true
default: ""
- variable: password
label: "Password"
schema:
type: string
required: true
default: ""
- variable: forwardAuth
label: "forwardAuth"
schema:
type: list
default: []
items:
- variable: basicAuthEntry
label: ""
schema:
additional_attrs: true
type: dict
attrs:
- variable: name
label: "Name"
schema:
type: string
required: true
default: ""
- variable: address
label: "Address"
schema:
type: string
required: true
default: ""
- variable: trustForwardHeader
label: "trustForwardHeader"
schema:
type: boolean
default: false
- variable: authResponseHeadersRegex
label: "authResponseHeadersRegex"
schema:
type: string
default: ""
- variable: authResponseHeaders
label: "authResponseHeaders"
schema:
type: list
default: []
items:
- variable: authResponseHeadersEntry
label: ""
schema:
type: string
default: ""
- variable: authRequestHeaders
label: "authRequestHeaders"
schema:
type: list
default: []
items:
- variable: authRequestHeadersEntry
label: ""
schema:
type: string
default: ""
- variable: chain
label: "chain"
schema:
type: list
default: []
items:
- variable: chainEntry
label: ""
schema:
additional_attrs: true
type: dict
attrs:
- variable: name
label: "Name"
schema:
type: string
required: true
- variable: middlewares
label: "Middlewares to Chain"
schema:
type: list
default: []
items:
- variable: name
label: "Name"
schema:
type: string
required: true
default: ""
- variable: redirectScheme
label: "redirectScheme"
schema:
type: list
default: []
items:
- variable: redirectSchemeEntry
label: ""
schema:
additional_attrs: true
type: dict
attrs:
- variable: name
label: "Name"
schema:
type: string
required: true
- variable: scheme
label: "Scheme"
schema:
type: string
required: true
default: "https"
enum:
- value: "https"
description: "https"
- value: "http"
description: "http"
- variable: permanent
label: "Permanent"
schema:
type: boolean
default: false
- variable: rateLimit
label: "rateLimit"
schema:
type: list
default: []
items:
- variable: rateLimitEntry
label: ""
schema:
additional_attrs: true
type: dict
attrs:
- variable: name
label: "Name"
schema:
type: string
required: true
- variable: average
label: "Average"
schema:
type: int
required: true
default: 300
- variable: burst
label: "Burst"
schema:
type: int
required: true
default: 200
- variable: redirectRegex
label: "redirectRegex"
schema:
type: list
default: []
items:
- variable: redirectRegexEntry
label: ""
schema:
additional_attrs: true
type: dict
attrs:
- variable: name
label: "Name"
schema:
type: string
required: true
- variable: regex
label: "Regex"
schema:
type: string
required: true
default: ""
- variable: replacement
label: "Replacement"
schema:
type: string
required: true
default: ""
- variable: permanent
label: "Permanent"
schema:
type: boolean
default: false
- variable: stripPrefixRegex
label: "stripPrefixRegex"
schema:
type: list
default: []
items:
- variable: stripPrefixRegexEntry
label: ""
schema:
additional_attrs: true
type: dict
attrs:
- variable: name
label: "Name"
schema:
type: string
required: true
- variable: regex
label: "Regex"
schema:
type: list
default: []
items:
- variable: regexEntry
label: "Regex"
schema:
type: string
required: true
default: ""
- variable: ipWhiteList
label: "ipWhiteList"
schema:
type: list
default: []
items:
- variable: ipWhiteListEntry
label: ""
schema:
additional_attrs: true
type: dict
attrs:
- variable: name
label: "Name"
schema:
type: string
required: true
default: ""
- variable: sourceRange
label: "Source Range"
schema:
type: list
default: []
items:
- variable: sourceRangeEntry
label: ""
schema:
type: string
required: true
default: ""
- variable: ipStrategy
label: "IP Strategy"
schema:
additional_attrs: true
type: dict
attrs:
- variable: depth
label: "Depth"
schema:
type: int
required: true
- variable: excludedIPs
label: "Excluded IPs"
schema:
type: list
default: []
items:
- variable: excludedIPsEntry
label: ""
schema:
type: string
required: true
default: ""
- variable: themePark
label: "theme.park"
schema:
type: list
default: []
items:
- variable: themeParkEntry
label: ""
schema:
additional_attrs: true
type: dict
attrs:
- variable: name
label: "Name"
description: This is a 3rd party plugin and not maintained by TrueCharts,
for more information go to <a href="https://github.com/packruler/traefik-themepark">traefik-themepark</a>
schema:
type: string
required: true
- variable: appName
label: App Name
description: Lower case, name of the app to be themed.
<br />Go to <a href="https://docs.theme-park.dev/themes/">https://docs.theme-park.dev/themes/</a> to see supported apps.
schema:
type: string
required: true
- variable: themeName
label: Theme Name
description: Lower case, name of the theme to be applied.
<br />Go to <a href="https://docs.theme-park.dev/theme-options/">https://docs.theme-park.dev/theme-options/</a> to see supported themes.
schema:
type: string
required: true
- variable: baseUrl
label: Base URL
description: Replace `https://theme-park.dev` URL for self-hosting reference.
schema:
type: string
required: true
default: https://theme-park.dev
- variable: addons
label: Addons
schema:
type: list
default: []
items:
- variable: addonEntry
label: "Addon"
description: Currently only supports 'darker' and '4k-logo' for *arr apps.
<br />Go to <a href="https://docs.theme-park.dev/themes/addons/">https://docs.theme-park.dev/themes/addons/</a> for Addon information.
<br />Go to <a href="https://github.com/packruler/traefik-themepark">https://github.com/packruler/traefik-themepark</a> for more context on plugin
schema:
type: string
required: true
default: ""
# Include{basicAuth}
# Include{forwardAuth}
# Include{chain}
# Include{redirectScheme}
# Include{rateLimit}
# Include{redirectRegex}
# Include{stripPrefixRegex}
# Include{ipWhitelist}
# Include{themePark}
# Include{realIP}
# Include{addPrefix}
- variable: service
group: "Networking and Services"
label: "Configure Service Entrypoint"
@@ -158,6 +158,12 @@ args:
- "--experimental.plugins.traefik-themepark.version={{ .Values.middlewares.themeParkVersion }}"
{{- end }}
{{/* End of theme.park */}}
{{/* RealIP */}}
{{- if .Values.middlewares.realIP }}
- "--experimental.plugins.traefik-real-ip.modulename=github.com/soulbalz/traefik-real-ip"
- "--experimental.plugins.traefik-real-ip.version={{ .Values.middlewares.realIPVersion }}"
{{- end }}
{{/* End of RealIP */}}
{{- with .Values.additionalArguments }}
{{- range . }}
- {{ . | quote }}
@@ -0,0 +1,17 @@
{{- $values := .Values }}
{{- $namespace := ( printf "ix-%s" .Release.Name ) }}
{{- if or ( not .Values.ingressClass.enabled ) ( and ( .Values.ingressClass.enabled ) ( .Values.ingressClass.isDefaultClass ) ) }}
{{- $namespace = "default" }}
{{- end }}
{{- range $index, $middlewareData := .Values.middlewares.addPrefix }}
---
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
name: {{ $middlewareData.name }}
namespace: {{ $namespace }}
spec:
addPrefix:
prefix: {{ $middlewareData.prefix }}
{{- end }}
@@ -0,0 +1,21 @@
{{- $values := .Values }}
{{- $namespace := ( printf "ix-%s" .Release.Name ) }}
{{- if or ( not .Values.ingressClass.enabled ) ( and ( .Values.ingressClass.enabled ) ( .Values.ingressClass.isDefaultClass ) ) }}
{{- $namespace = "default" }}
{{- end }}
{{- range $index, $middlewareData := .Values.middlewares.realIP }}
---
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
name: {{ $middlewareData.name }}
namespace: {{ $namespace }}
spec:
plugin:
traefik-real-ip:
excludednets:
{{- range $middlewareData.excludedNetworks }}
- {{ . | quote }}
{{- end }}
{{- end }}
+14 -11
View File
@@ -12,14 +12,6 @@ ingressClass:
# Use to force a networking.k8s.io API Version for certain CI/CD applications. E.g. "v1beta1"
fallbackApiVersion: ""
# -- Deprecated (will be removed later)
# -- Activate Pilot integration
pilot:
enabled: false
token: ""
# Toggle Pilot Dashboard
# dashboard: false
# -- Create an IngressRoute for the dashboard
ingressRoute:
dashboard:
@@ -359,8 +351,7 @@ middlewares:
# ipStrategy:
# depth: 2
# excludedIPs: []
# -- Currently requires to enable Traefik Pilot.
# -- Until it's deprecated.
themeParkVersion: v1.2.2
themePark: []
# - name: themeParkName
# -- Supported apps, lower case name
@@ -372,7 +363,19 @@ middlewares:
# theme: themenamehere
# -- https://theme-park.dev or a self hosted url
# baseUrl: https://theme-park.dev
themeParkVersion: v1.2.1
realIPVersion: v1.0.3
# Sets X-Real-Ip with an IP from the X-Forwarded-For or
# Cf-Connecting-Ip (If from Cloudflare)
# Evaluation of those headers will go from last to first
realIP: []
# - name: realIPName
# -- The real IP will be the first one that is
# -- not included in any of the CIDRs passed here
# excludedNetworks:
# - 1.1.1.1/24
addPrefix: []
# - name: addPrefixName
# prefix: "/foo"
portalhook:
enabled: true