Created
November 1, 2020 03:18
-
-
Save dfang/0e9a8f13b1d4b02f5a7302b3188c9f73 to your computer and use it in GitHub Desktop.
traefik IngressRoute
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############ | |
############ | |
# REDIRECT TO HTTPS MIDDLEWARE | |
--- | |
apiVersion: traefik.containo.us/v1alpha1 | |
kind: Middleware | |
metadata: | |
name: redirect-http-to-https | |
spec: | |
redirectScheme: | |
scheme: https | |
permanent: true | |
# HTTP (web endpoint) with redirect-to-https middleware | |
--- | |
apiVersion: traefik.containo.us/v1alpha1 | |
kind: IngressRoute | |
metadata: | |
name: whoami | |
namespace: whoami | |
spec: | |
entryPoints: | |
- web | |
routes: | |
- match: Host("whoami.jdwl.in") | |
kind: Rule | |
services: | |
- name: whoami | |
port: 80 | |
middlewares: | |
- name: http-redirect-to-https | |
# HTTPS (websecure endpoint) | |
--- | |
apiVersion: traefik.containo.us/v1alpha1 | |
kind: IngressRoute | |
metadata: | |
name: whoami-https | |
namespace: whoami | |
spec: | |
entryPoints: | |
- websecure | |
routes: | |
- match: Host(`whoami.jdwl.in`) | |
kind: Rule | |
services: | |
- name: whoami | |
port: 80 | |
tls: | |
secretName: wildcard-cert-prod |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Global HTTP Redirect To HTTPS
如果是用helm chart安装的话:
values.yaml
效果:
http ingressroute 那里就不用加http-redirect-to-https 的middleware了
甚至都不用定义http ingressRoute了, 只需定义https 版的ingressRoute