github.com/ddev/ddev@v1.23.2-0.20240519125000-d824ffe36ff3/pkg/ddevapp/traefik_config_template.yaml (about) 1 #ddev-generated 2 3 http: 4 routers: 5 {{$appname := .App.Name}}{{ range $s := .RoutingTable }} 6 {{ if not $s.HTTPS }} 7 {{$appname}}-{{$s.InternalServiceName}}-{{$s.InternalServicePort}}-http: 8 {{if not $.UseLetsEncrypt}}{{/* Let's Encrypt only works with Host(), but we need HostRegex() for wildcards*/}} 9 rule: HostRegexp({{ range $i, $h := $s.ExternalHostnames }}{{if $i}}, {{end}}`{{$h}}`{{end}}) 10 {{else}} 11 rule: Host({{ range $i, $h := $s.ExternalHostnames }}{{if $i}}, {{end}}`{{$h}}`{{end}}) 12 {{end}} 13 middlewares: 14 - autodetect 15 service: "{{$appname}}-{{$s.InternalServiceName}}-{{$s.InternalServicePort}}-http" 16 tls: false 17 entrypoints: 18 - http-{{$s.ExternalPort}} 19 {{ end }}{{ end }} 20 {{$appname := .App.Name}}{{ range $s := .RoutingTable }}{{ if $s.HTTPS }} 21 {{$appname}}-{{$s.InternalServiceName}}-{{$s.InternalServicePort}}-https: 22 {{if not $.UseLetsEncrypt}}{{/* Let's Encrypt only works with Host(), but we need HostRegex() for wildcards*/}} 23 rule: HostRegexp({{ range $i, $h := $s.ExternalHostnames }}{{if $i}}, {{end}}`{{$h}}`{{end}}) 24 {{else}} 25 rule: Host({{ range $i, $h := $s.ExternalHostnames }}{{if $i}}, {{end}}`{{$h}}`{{end}}) 26 {{end}} 27 middlewares: 28 - autodetect 29 service: "{{$appname}}-{{$s.InternalServiceName}}-{{$s.InternalServicePort}}-https" 30 {{ if not $.UseLetsEncrypt }} 31 tls: true 32 {{ else }} 33 tls: 34 certResolver: acmeresolver 35 {{end}} 36 entrypoints: 37 - http-{{$s.ExternalPort}} 38 {{ end }} 39 {{ end }} 40 41 # autodetect won't be needed in Traefik 3 https://github.com/traefik/traefik/pull/9546 42 middlewares: 43 autodetect: 44 contentType: 45 autoDetect: false 46 47 services: 48 {{$appname := .App.Name}}{{ range $s := .RoutingTable }}{{ if $s.HTTPS }} 49 {{$appname}}-{{ $s.InternalServiceName }}-{{ $s.InternalServicePort }}-https: 50 {{ else }} 51 {{$appname}}-{{ $s.InternalServiceName }}-{{ $s.InternalServicePort }}-http:{{end}} 52 loadbalancer: 53 servers: 54 - url: http://ddev-{{$appname}}-{{$s.InternalServiceName}}:{{$s.InternalServicePort}} 55 {{ end }} 56 57 {{ if not .UseLetsEncrypt }}{{/* let's encrypt doesn't work if there's already a provided cert */}} 58 tls: 59 certificates: 60 - certFile: {{ .TargetCertsPath }}/{{ .App.Name }}.crt 61 keyFile: {{ .TargetCertsPath }}/{{ .App.Name }}.key 62 {{end}}