Add SSLForceHost support.
This commit is contained in:
parent
dce65ab9c2
commit
b7d20496f3
37 changed files with 389 additions and 40 deletions
2
Gopkg.lock
generated
2
Gopkg.lock
generated
|
@ -1189,7 +1189,7 @@
|
||||||
branch = "v1"
|
branch = "v1"
|
||||||
name = "github.com/unrolled/secure"
|
name = "github.com/unrolled/secure"
|
||||||
packages = ["."]
|
packages = ["."]
|
||||||
revision = "88720c9cbecfcf2eceb9bb4311ad6e398a8381ed"
|
revision = "a1cf62cc2159fff407728f118c41aece76c397fa"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/urfave/negroni"
|
name = "github.com/urfave/negroni"
|
||||||
|
|
|
@ -262,6 +262,7 @@ var _templatesConsul_catalogTmpl = []byte(`[backends]
|
||||||
SSLRedirect = {{ $headers.SSLRedirect }}
|
SSLRedirect = {{ $headers.SSLRedirect }}
|
||||||
SSLTemporaryRedirect = {{ $headers.SSLTemporaryRedirect }}
|
SSLTemporaryRedirect = {{ $headers.SSLTemporaryRedirect }}
|
||||||
SSLHost = "{{ $headers.SSLHost }}"
|
SSLHost = "{{ $headers.SSLHost }}"
|
||||||
|
SSLForceHost = {{ $headers.SSLForceHost }}
|
||||||
STSSeconds = {{ $headers.STSSeconds }}
|
STSSeconds = {{ $headers.STSSeconds }}
|
||||||
STSIncludeSubdomains = {{ $headers.STSIncludeSubdomains }}
|
STSIncludeSubdomains = {{ $headers.STSIncludeSubdomains }}
|
||||||
STSPreload = {{ $headers.STSPreload }}
|
STSPreload = {{ $headers.STSPreload }}
|
||||||
|
@ -670,6 +671,7 @@ var _templatesDockerTmpl = []byte(`{{$backendServers := .Servers}}
|
||||||
SSLRedirect = {{ $headers.SSLRedirect }}
|
SSLRedirect = {{ $headers.SSLRedirect }}
|
||||||
SSLTemporaryRedirect = {{ $headers.SSLTemporaryRedirect }}
|
SSLTemporaryRedirect = {{ $headers.SSLTemporaryRedirect }}
|
||||||
SSLHost = "{{ $headers.SSLHost }}"
|
SSLHost = "{{ $headers.SSLHost }}"
|
||||||
|
SSLForceHost = {{ $headers.SSLForceHost }}
|
||||||
STSSeconds = {{ $headers.STSSeconds }}
|
STSSeconds = {{ $headers.STSSeconds }}
|
||||||
STSIncludeSubdomains = {{ $headers.STSIncludeSubdomains }}
|
STSIncludeSubdomains = {{ $headers.STSIncludeSubdomains }}
|
||||||
STSPreload = {{ $headers.STSPreload }}
|
STSPreload = {{ $headers.STSPreload }}
|
||||||
|
@ -929,6 +931,7 @@ var _templatesEcsTmpl = []byte(`[backends]
|
||||||
SSLRedirect = {{ $headers.SSLRedirect }}
|
SSLRedirect = {{ $headers.SSLRedirect }}
|
||||||
SSLTemporaryRedirect = {{ $headers.SSLTemporaryRedirect }}
|
SSLTemporaryRedirect = {{ $headers.SSLTemporaryRedirect }}
|
||||||
SSLHost = "{{ $headers.SSLHost }}"
|
SSLHost = "{{ $headers.SSLHost }}"
|
||||||
|
SSLForceHost = {{ $headers.SSLForceHost }}
|
||||||
STSSeconds = {{ $headers.STSSeconds }}
|
STSSeconds = {{ $headers.STSSeconds }}
|
||||||
STSIncludeSubdomains = {{ $headers.STSIncludeSubdomains }}
|
STSIncludeSubdomains = {{ $headers.STSIncludeSubdomains }}
|
||||||
STSPreload = {{ $headers.STSPreload }}
|
STSPreload = {{ $headers.STSPreload }}
|
||||||
|
@ -1141,6 +1144,7 @@ var _templatesKubernetesTmpl = []byte(`[backends]
|
||||||
SSLRedirect = {{ $frontend.Headers.SSLRedirect }}
|
SSLRedirect = {{ $frontend.Headers.SSLRedirect }}
|
||||||
SSLTemporaryRedirect = {{ $frontend.Headers.SSLTemporaryRedirect }}
|
SSLTemporaryRedirect = {{ $frontend.Headers.SSLTemporaryRedirect }}
|
||||||
SSLHost = "{{ $frontend.Headers.SSLHost }}"
|
SSLHost = "{{ $frontend.Headers.SSLHost }}"
|
||||||
|
SSLForceHost = {{ $frontend.Headers.SSLForceHost }}
|
||||||
STSSeconds = {{ $frontend.Headers.STSSeconds }}
|
STSSeconds = {{ $frontend.Headers.STSSeconds }}
|
||||||
STSIncludeSubdomains = {{ $frontend.Headers.STSIncludeSubdomains }}
|
STSIncludeSubdomains = {{ $frontend.Headers.STSIncludeSubdomains }}
|
||||||
STSPreload = {{ $frontend.Headers.STSPreload }}
|
STSPreload = {{ $frontend.Headers.STSPreload }}
|
||||||
|
@ -1346,6 +1350,7 @@ var _templatesKvTmpl = []byte(`[backends]
|
||||||
SSLRedirect = {{ $headers.SSLRedirect }}
|
SSLRedirect = {{ $headers.SSLRedirect }}
|
||||||
SSLTemporaryRedirect = {{ $headers.SSLTemporaryRedirect }}
|
SSLTemporaryRedirect = {{ $headers.SSLTemporaryRedirect }}
|
||||||
SSLHost = "{{ $headers.SSLHost }}"
|
SSLHost = "{{ $headers.SSLHost }}"
|
||||||
|
SSLForceHost = {{ $headers.SSLForceHost }}
|
||||||
STSSeconds = {{ $headers.STSSeconds }}
|
STSSeconds = {{ $headers.STSSeconds }}
|
||||||
STSIncludeSubdomains = {{ $headers.STSIncludeSubdomains }}
|
STSIncludeSubdomains = {{ $headers.STSIncludeSubdomains }}
|
||||||
STSPreload = {{ $headers.STSPreload }}
|
STSPreload = {{ $headers.STSPreload }}
|
||||||
|
@ -1647,6 +1652,7 @@ var _templatesMarathonTmpl = []byte(`{{ $apps := .Applications }}
|
||||||
SSLRedirect = {{ $headers.SSLRedirect }}
|
SSLRedirect = {{ $headers.SSLRedirect }}
|
||||||
SSLTemporaryRedirect = {{ $headers.SSLTemporaryRedirect }}
|
SSLTemporaryRedirect = {{ $headers.SSLTemporaryRedirect }}
|
||||||
SSLHost = "{{ $headers.SSLHost }}"
|
SSLHost = "{{ $headers.SSLHost }}"
|
||||||
|
SSLForceHost = {{ $headers.SSLForceHost }}
|
||||||
STSSeconds = {{ $headers.STSSeconds }}
|
STSSeconds = {{ $headers.STSSeconds }}
|
||||||
STSIncludeSubdomains = {{ $headers.STSIncludeSubdomains }}
|
STSIncludeSubdomains = {{ $headers.STSIncludeSubdomains }}
|
||||||
STSPreload = {{ $headers.STSPreload }}
|
STSPreload = {{ $headers.STSPreload }}
|
||||||
|
@ -1892,6 +1898,7 @@ var _templatesMesosTmpl = []byte(`[backends]
|
||||||
SSLRedirect = {{ $headers.SSLRedirect }}
|
SSLRedirect = {{ $headers.SSLRedirect }}
|
||||||
SSLTemporaryRedirect = {{ $headers.SSLTemporaryRedirect }}
|
SSLTemporaryRedirect = {{ $headers.SSLTemporaryRedirect }}
|
||||||
SSLHost = "{{ $headers.SSLHost }}"
|
SSLHost = "{{ $headers.SSLHost }}"
|
||||||
|
SSLForceHost = {{ $headers.SSLForceHost }}
|
||||||
STSSeconds = {{ $headers.STSSeconds }}
|
STSSeconds = {{ $headers.STSSeconds }}
|
||||||
STSIncludeSubdomains = {{ $headers.STSIncludeSubdomains }}
|
STSIncludeSubdomains = {{ $headers.STSIncludeSubdomains }}
|
||||||
STSPreload = {{ $headers.STSPreload }}
|
STSPreload = {{ $headers.STSPreload }}
|
||||||
|
@ -2190,6 +2197,7 @@ var _templatesRancherTmpl = []byte(`{{ $backendServers := .Backends }}
|
||||||
SSLRedirect = {{ $headers.SSLRedirect }}
|
SSLRedirect = {{ $headers.SSLRedirect }}
|
||||||
SSLTemporaryRedirect = {{ $headers.SSLTemporaryRedirect }}
|
SSLTemporaryRedirect = {{ $headers.SSLTemporaryRedirect }}
|
||||||
SSLHost = "{{ $headers.SSLHost }}"
|
SSLHost = "{{ $headers.SSLHost }}"
|
||||||
|
SSLForceHost = {{ $headers.SSLForceHost }}
|
||||||
STSSeconds = {{ $headers.STSSeconds }}
|
STSSeconds = {{ $headers.STSSeconds }}
|
||||||
STSIncludeSubdomains = {{ $headers.STSIncludeSubdomains }}
|
STSIncludeSubdomains = {{ $headers.STSIncludeSubdomains }}
|
||||||
STSPreload = {{ $headers.STSPreload }}
|
STSPreload = {{ $headers.STSPreload }}
|
||||||
|
|
|
@ -161,11 +161,13 @@ Additional settings can be defined using Consul Catalog tags.
|
||||||
| `<prefix>.frontend.headers.SSLRedirect=true` | Forces the frontend to redirect to SSL if a non-SSL request is sent. |
|
| `<prefix>.frontend.headers.SSLRedirect=true` | Forces the frontend to redirect to SSL if a non-SSL request is sent. |
|
||||||
| `<prefix>.frontend.headers.SSLTemporaryRedirect=true` | Forces the frontend to redirect to SSL if a non-SSL request is sent, but by sending a 302 instead of a 301. |
|
| `<prefix>.frontend.headers.SSLTemporaryRedirect=true` | Forces the frontend to redirect to SSL if a non-SSL request is sent, but by sending a 302 instead of a 301. |
|
||||||
| `<prefix>.frontend.headers.SSLHost=HOST` | This setting configures the hostname that redirects will be based on. Default is "", which is the same host as the request. |
|
| `<prefix>.frontend.headers.SSLHost=HOST` | This setting configures the hostname that redirects will be based on. Default is "", which is the same host as the request. |
|
||||||
|
| `<prefix>.frontend.headers.SSLForceHost=true` | If `SSLForceHost` is `true` and `SSLHost` is set, requests will be forced to use `SSLHost` even the ones that are already using SSL. Default is false. |
|
||||||
| `<prefix>.frontend.headers.SSLProxyHeaders=EXPR` | Header combinations that would signify a proper SSL Request (Such as `X-Forwarded-For:https`).<br>Format: <code>HEADER:value||HEADER2:value2</code> |
|
| `<prefix>.frontend.headers.SSLProxyHeaders=EXPR` | Header combinations that would signify a proper SSL Request (Such as `X-Forwarded-For:https`).<br>Format: <code>HEADER:value||HEADER2:value2</code> |
|
||||||
| `<prefix>.frontend.headers.STSSeconds=315360000` | Sets the max-age of the STS header. |
|
| `<prefix>.frontend.headers.STSSeconds=315360000` | Sets the max-age of the STS header. |
|
||||||
| `<prefix>.frontend.headers.STSIncludeSubdomains=true` | Adds the `IncludeSubdomains` section of the STS header. |
|
| `<prefix>.frontend.headers.STSIncludeSubdomains=true` | Adds the `IncludeSubdomains` section of the STS header. |
|
||||||
| `<prefix>.frontend.headers.STSPreload=true` | Adds the preload flag to the STS header. |
|
| `<prefix>.frontend.headers.STSPreload=true` | Adds the preload flag to the STS header. |
|
||||||
|
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
If you want that Træfik uses Consul tags correctly you need to defined them like that:
|
If you want that Træfik uses Consul tags correctly you need to defined them like that:
|
||||||
|
|
|
@ -271,6 +271,7 @@ Or if your service references external network use it's name instead.
|
||||||
| `traefik.frontend.headers.SSLRedirect=true` | Forces the frontend to redirect to SSL if a non-SSL request is sent. |
|
| `traefik.frontend.headers.SSLRedirect=true` | Forces the frontend to redirect to SSL if a non-SSL request is sent. |
|
||||||
| `traefik.frontend.headers.SSLTemporaryRedirect=true` | Forces the frontend to redirect to SSL if a non-SSL request is sent, but by sending a 302 instead of a 301. |
|
| `traefik.frontend.headers.SSLTemporaryRedirect=true` | Forces the frontend to redirect to SSL if a non-SSL request is sent, but by sending a 302 instead of a 301. |
|
||||||
| `traefik.frontend.headers.SSLHost=HOST` | This setting configures the hostname that redirects will be based on. Default is "", which is the same host as the request. |
|
| `traefik.frontend.headers.SSLHost=HOST` | This setting configures the hostname that redirects will be based on. Default is "", which is the same host as the request. |
|
||||||
|
| `traefik.frontend.headers.SSLForceHost=true` | If `SSLForceHost` is `true` and `SSLHost` is set, requests will be forced to use `SSLHost` even the ones that are already using SSL. Default is false. |
|
||||||
| `traefik.frontend.headers.SSLProxyHeaders=EXPR` | Header combinations that would signify a proper SSL Request (Such as `X-Forwarded-For:https`).<br>Format: <code>HEADER:value||HEADER2:value2</code> |
|
| `traefik.frontend.headers.SSLProxyHeaders=EXPR` | Header combinations that would signify a proper SSL Request (Such as `X-Forwarded-For:https`).<br>Format: <code>HEADER:value||HEADER2:value2</code> |
|
||||||
| `traefik.frontend.headers.STSSeconds=315360000` | Sets the max-age of the STS header. |
|
| `traefik.frontend.headers.STSSeconds=315360000` | Sets the max-age of the STS header. |
|
||||||
| `traefik.frontend.headers.STSIncludeSubdomains=true` | Adds the `IncludeSubdomains` section of the STS header. |
|
| `traefik.frontend.headers.STSIncludeSubdomains=true` | Adds the `IncludeSubdomains` section of the STS header. |
|
||||||
|
@ -337,6 +338,7 @@ Segment labels override the default behavior.
|
||||||
| `traefik.<segment_name>.frontend.headers.SSLRedirect=true` | Same as `traefik.frontend.headers.SSLRedirect` |
|
| `traefik.<segment_name>.frontend.headers.SSLRedirect=true` | Same as `traefik.frontend.headers.SSLRedirect` |
|
||||||
| `traefik.<segment_name>.frontend.headers.SSLTemporaryRedirect=true` | Same as `traefik.frontend.headers.SSLTemporaryRedirect` |
|
| `traefik.<segment_name>.frontend.headers.SSLTemporaryRedirect=true` | Same as `traefik.frontend.headers.SSLTemporaryRedirect` |
|
||||||
| `traefik.<segment_name>.frontend.headers.SSLHost=HOST` | Same as `traefik.frontend.headers.SSLHost` |
|
| `traefik.<segment_name>.frontend.headers.SSLHost=HOST` | Same as `traefik.frontend.headers.SSLHost` |
|
||||||
|
| `traefik.<segment_name>.frontend.headers.SSLForceHost=true` | Same as `traefik.frontend.headers.SSLForceHost` |
|
||||||
| `traefik.<segment_name>.frontend.headers.SSLProxyHeaders=EXPR` | Same as `traefik.frontend.headers.SSLProxyHeaders=EXPR` |
|
| `traefik.<segment_name>.frontend.headers.SSLProxyHeaders=EXPR` | Same as `traefik.frontend.headers.SSLProxyHeaders=EXPR` |
|
||||||
| `traefik.<segment_name>.frontend.headers.STSSeconds=315360000` | Same as `traefik.frontend.headers.STSSeconds=315360000` |
|
| `traefik.<segment_name>.frontend.headers.STSSeconds=315360000` | Same as `traefik.frontend.headers.STSSeconds=315360000` |
|
||||||
| `traefik.<segment_name>.frontend.headers.STSIncludeSubdomains=true` | Same as `traefik.frontend.headers.STSIncludeSubdomains=true` |
|
| `traefik.<segment_name>.frontend.headers.STSIncludeSubdomains=true` | Same as `traefik.frontend.headers.STSIncludeSubdomains=true` |
|
||||||
|
|
|
@ -205,6 +205,7 @@ Labels can be used on task containers to override default behaviour:
|
||||||
| `traefik.frontend.headers.SSLRedirect=true` | Forces the frontend to redirect to SSL if a non-SSL request is sent. |
|
| `traefik.frontend.headers.SSLRedirect=true` | Forces the frontend to redirect to SSL if a non-SSL request is sent. |
|
||||||
| `traefik.frontend.headers.SSLTemporaryRedirect=true` | Forces the frontend to redirect to SSL if a non-SSL request is sent, but by sending a 302 instead of a 301. |
|
| `traefik.frontend.headers.SSLTemporaryRedirect=true` | Forces the frontend to redirect to SSL if a non-SSL request is sent, but by sending a 302 instead of a 301. |
|
||||||
| `traefik.frontend.headers.SSLHost=HOST` | This setting configures the hostname that redirects will be based on. Default is "", which is the same host as the request. |
|
| `traefik.frontend.headers.SSLHost=HOST` | This setting configures the hostname that redirects will be based on. Default is "", which is the same host as the request. |
|
||||||
|
| `traefik.frontend.headers.SSLForceHost=true` | If `SSLForceHost` is `true` and `SSLHost` is set, requests will be forced to use `SSLHost` even the ones that are already using SSL. Default is false. |
|
||||||
| `traefik.frontend.headers.SSLProxyHeaders=EXPR` | Header combinations that would signify a proper SSL Request (Such as `X-Forwarded-For:https`).<br>Format: <code>HEADER:value||HEADER2:value2</code> |
|
| `traefik.frontend.headers.SSLProxyHeaders=EXPR` | Header combinations that would signify a proper SSL Request (Such as `X-Forwarded-For:https`).<br>Format: <code>HEADER:value||HEADER2:value2</code> |
|
||||||
| `traefik.frontend.headers.STSSeconds=315360000` | Sets the max-age of the STS header. |
|
| `traefik.frontend.headers.STSSeconds=315360000` | Sets the max-age of the STS header. |
|
||||||
| `traefik.frontend.headers.STSIncludeSubdomains=true` | Adds the `IncludeSubdomains` section of the STS header. |
|
| `traefik.frontend.headers.STSIncludeSubdomains=true` | Adds the `IncludeSubdomains` section of the STS header. |
|
||||||
|
|
|
@ -235,6 +235,7 @@ The following security annotations are applicable on the Ingress object:
|
||||||
| `ingress.kubernetes.io/ssl-redirect: "true"` | Forces the frontend to redirect to SSL if a non-SSL request is sent. |
|
| `ingress.kubernetes.io/ssl-redirect: "true"` | Forces the frontend to redirect to SSL if a non-SSL request is sent. |
|
||||||
| `ingress.kubernetes.io/ssl-temporary-redirect: "true"` | Forces the frontend to redirect to SSL if a non-SSL request is sent, but by sending a 302 instead of a 301. |
|
| `ingress.kubernetes.io/ssl-temporary-redirect: "true"` | Forces the frontend to redirect to SSL if a non-SSL request is sent, but by sending a 302 instead of a 301. |
|
||||||
| `ingress.kubernetes.io/ssl-host: HOST` | This setting configures the hostname that redirects will be based on. Default is "", which is the same host as the request. |
|
| `ingress.kubernetes.io/ssl-host: HOST` | This setting configures the hostname that redirects will be based on. Default is "", which is the same host as the request. |
|
||||||
|
| `ingress.kubernetes.io/ssl-force-host: "true"` | If `SSLForceHost` is `true` and `SSLHost` is set, requests will be forced to use `SSLHost` even the ones that are already using SSL. Default is false. |
|
||||||
| `ingress.kubernetes.io/ssl-proxy-headers: EXPR` | Header combinations that would signify a proper SSL Request (Such as `X-Forwarded-For:https`). Format: <code>HEADER:value||HEADER2:value2</code> |
|
| `ingress.kubernetes.io/ssl-proxy-headers: EXPR` | Header combinations that would signify a proper SSL Request (Such as `X-Forwarded-For:https`). Format: <code>HEADER:value||HEADER2:value2</code> |
|
||||||
|
|
||||||
### Authentication
|
### Authentication
|
||||||
|
|
|
@ -242,6 +242,7 @@ The following labels can be defined on Marathon applications. They adjust the be
|
||||||
| `traefik.frontend.headers.SSLRedirect=true` | Forces the frontend to redirect to SSL if a non-SSL request is sent. |
|
| `traefik.frontend.headers.SSLRedirect=true` | Forces the frontend to redirect to SSL if a non-SSL request is sent. |
|
||||||
| `traefik.frontend.headers.SSLTemporaryRedirect=true` | Forces the frontend to redirect to SSL if a non-SSL request is sent, but by sending a 302 instead of a 301. |
|
| `traefik.frontend.headers.SSLTemporaryRedirect=true` | Forces the frontend to redirect to SSL if a non-SSL request is sent, but by sending a 302 instead of a 301. |
|
||||||
| `traefik.frontend.headers.SSLHost=HOST` | This setting configures the hostname that redirects will be based on. Default is "", which is the same host as the request. |
|
| `traefik.frontend.headers.SSLHost=HOST` | This setting configures the hostname that redirects will be based on. Default is "", which is the same host as the request. |
|
||||||
|
| `traefik.frontend.headers.SSLForceHost=true` | If `SSLForceHost` is `true` and `SSLHost` is set, requests will be forced to use `SSLHost` even the ones that are already using SSL. Default is false. |
|
||||||
| `traefik.frontend.headers.SSLProxyHeaders=EXPR` | Header combinations that would signify a proper SSL Request (Such as `X-Forwarded-For:https`).<br>Format: <code>HEADER:value||HEADER2:value2</code> |
|
| `traefik.frontend.headers.SSLProxyHeaders=EXPR` | Header combinations that would signify a proper SSL Request (Such as `X-Forwarded-For:https`).<br>Format: <code>HEADER:value||HEADER2:value2</code> |
|
||||||
| `traefik.frontend.headers.STSSeconds=315360000` | Sets the max-age of the STS header. |
|
| `traefik.frontend.headers.STSSeconds=315360000` | Sets the max-age of the STS header. |
|
||||||
| `traefik.frontend.headers.STSIncludeSubdomains=true` | Adds the `IncludeSubdomains` section of the STS header. |
|
| `traefik.frontend.headers.STSIncludeSubdomains=true` | Adds the `IncludeSubdomains` section of the STS header. |
|
||||||
|
@ -309,6 +310,7 @@ Segment labels override the default behavior.
|
||||||
| `traefik.<segment_name>.frontend.headers.SSLRedirect=true` | Same as `traefik.frontend.headers.SSLRedirect` |
|
| `traefik.<segment_name>.frontend.headers.SSLRedirect=true` | Same as `traefik.frontend.headers.SSLRedirect` |
|
||||||
| `traefik.<segment_name>.frontend.headers.SSLTemporaryRedirect=true` | Same as `traefik.frontend.headers.SSLTemporaryRedirect` |
|
| `traefik.<segment_name>.frontend.headers.SSLTemporaryRedirect=true` | Same as `traefik.frontend.headers.SSLTemporaryRedirect` |
|
||||||
| `traefik.<segment_name>.frontend.headers.SSLHost=HOST` | Same as `traefik.frontend.headers.SSLHost` |
|
| `traefik.<segment_name>.frontend.headers.SSLHost=HOST` | Same as `traefik.frontend.headers.SSLHost` |
|
||||||
|
| `traefik.<segment_name>.frontend.headers.SSLForceHost=true` | Same as `traefik.frontend.headers.SSLForceHost` |
|
||||||
| `traefik.<segment_name>.frontend.headers.SSLProxyHeaders=EXPR` | Same as `traefik.frontend.headers.SSLProxyHeaders=EXPR` |
|
| `traefik.<segment_name>.frontend.headers.SSLProxyHeaders=EXPR` | Same as `traefik.frontend.headers.SSLProxyHeaders=EXPR` |
|
||||||
| `traefik.<segment_name>.frontend.headers.STSSeconds=315360000` | Same as `traefik.frontend.headers.STSSeconds=315360000` |
|
| `traefik.<segment_name>.frontend.headers.STSSeconds=315360000` | Same as `traefik.frontend.headers.STSSeconds=315360000` |
|
||||||
| `traefik.<segment_name>.frontend.headers.STSIncludeSubdomains=true` | Same as `traefik.frontend.headers.STSIncludeSubdomains=true` |
|
| `traefik.<segment_name>.frontend.headers.STSIncludeSubdomains=true` | Same as `traefik.frontend.headers.STSIncludeSubdomains=true` |
|
||||||
|
|
|
@ -177,6 +177,7 @@ The following labels can be defined on Mesos tasks. They adjust the behavior for
|
||||||
| `traefik.frontend.headers.SSLRedirect=true` | Forces the frontend to redirect to SSL if a non-SSL request is sent. |
|
| `traefik.frontend.headers.SSLRedirect=true` | Forces the frontend to redirect to SSL if a non-SSL request is sent. |
|
||||||
| `traefik.frontend.headers.SSLTemporaryRedirect=true` | Forces the frontend to redirect to SSL if a non-SSL request is sent, but by sending a 302 instead of a 301. |
|
| `traefik.frontend.headers.SSLTemporaryRedirect=true` | Forces the frontend to redirect to SSL if a non-SSL request is sent, but by sending a 302 instead of a 301. |
|
||||||
| `traefik.frontend.headers.SSLHost=HOST` | This setting configures the hostname that redirects will be based on. Default is "", which is the same host as the request. |
|
| `traefik.frontend.headers.SSLHost=HOST` | This setting configures the hostname that redirects will be based on. Default is "", which is the same host as the request. |
|
||||||
|
| `traefik.frontend.headers.SSLForceHost=true` | If `SSLForceHost` is `true` and `SSLHost` is set, requests will be forced to use `SSLHost` even the ones that are already using SSL. Default is false. |
|
||||||
| `traefik.frontend.headers.SSLProxyHeaders=EXPR` | Header combinations that would signify a proper SSL Request (Such as `X-Forwarded-For:https`).<br>Format: <code>HEADER:value||HEADER2:value2</code> |
|
| `traefik.frontend.headers.SSLProxyHeaders=EXPR` | Header combinations that would signify a proper SSL Request (Such as `X-Forwarded-For:https`).<br>Format: <code>HEADER:value||HEADER2:value2</code> |
|
||||||
| `traefik.frontend.headers.STSSeconds=315360000` | Sets the max-age of the STS header. |
|
| `traefik.frontend.headers.STSSeconds=315360000` | Sets the max-age of the STS header. |
|
||||||
| `traefik.frontend.headers.STSIncludeSubdomains=true` | Adds the `IncludeSubdomains` section of the STS header. |
|
| `traefik.frontend.headers.STSIncludeSubdomains=true` | Adds the `IncludeSubdomains` section of the STS header. |
|
||||||
|
|
|
@ -209,6 +209,7 @@ Labels can be used on task containers to override default behavior:
|
||||||
| `traefik.frontend.headers.SSLRedirect=true` | Forces the frontend to redirect to SSL if a non-SSL request is sent. |
|
| `traefik.frontend.headers.SSLRedirect=true` | Forces the frontend to redirect to SSL if a non-SSL request is sent. |
|
||||||
| `traefik.frontend.headers.SSLTemporaryRedirect=true` | Forces the frontend to redirect to SSL if a non-SSL request is sent, but by sending a 302 instead of a 301. |
|
| `traefik.frontend.headers.SSLTemporaryRedirect=true` | Forces the frontend to redirect to SSL if a non-SSL request is sent, but by sending a 302 instead of a 301. |
|
||||||
| `traefik.frontend.headers.SSLHost=HOST` | This setting configures the hostname that redirects will be based on. Default is "", which is the same host as the request. |
|
| `traefik.frontend.headers.SSLHost=HOST` | This setting configures the hostname that redirects will be based on. Default is "", which is the same host as the request. |
|
||||||
|
| `traefik.frontend.headers.SSLForceHost=true` | If `SSLForceHost` is `true` and `SSLHost` is set, requests will be forced to use `SSLHost` even the ones that are already using SSL. Default is false. |
|
||||||
| `traefik.frontend.headers.SSLProxyHeaders=EXPR` | Header combinations that would signify a proper SSL Request (Such as `X-Forwarded-For:https`).<br>Format: <code>HEADER:value||HEADER2:value2</code> |
|
| `traefik.frontend.headers.SSLProxyHeaders=EXPR` | Header combinations that would signify a proper SSL Request (Such as `X-Forwarded-For:https`).<br>Format: <code>HEADER:value||HEADER2:value2</code> |
|
||||||
| `traefik.frontend.headers.STSSeconds=315360000` | Sets the max-age of the STS header. |
|
| `traefik.frontend.headers.STSSeconds=315360000` | Sets the max-age of the STS header. |
|
||||||
| `traefik.frontend.headers.STSIncludeSubdomains=true` | Adds the `IncludeSubdomains` section of the STS header. |
|
| `traefik.frontend.headers.STSIncludeSubdomains=true` | Adds the `IncludeSubdomains` section of the STS header. |
|
||||||
|
@ -275,6 +276,7 @@ Segment labels override the default behavior.
|
||||||
| `traefik.<segment_name>.frontend.headers.SSLRedirect=true` | overrides `traefik.frontend.headers.SSLRedirect` |
|
| `traefik.<segment_name>.frontend.headers.SSLRedirect=true` | overrides `traefik.frontend.headers.SSLRedirect` |
|
||||||
| `traefik.<segment_name>.frontend.headers.SSLTemporaryRedirect=true` | overrides `traefik.frontend.headers.SSLTemporaryRedirect` |
|
| `traefik.<segment_name>.frontend.headers.SSLTemporaryRedirect=true` | overrides `traefik.frontend.headers.SSLTemporaryRedirect` |
|
||||||
| `traefik.<segment_name>.frontend.headers.SSLHost=HOST` | overrides `traefik.frontend.headers.SSLHost` |
|
| `traefik.<segment_name>.frontend.headers.SSLHost=HOST` | overrides `traefik.frontend.headers.SSLHost` |
|
||||||
|
| `traefik.<segment_name>.frontend.headers.SSLForceHost=true` | overrides `traefik.frontend.headers.SSLForceHost` |
|
||||||
| `traefik.<segment_name>.frontend.headers.SSLProxyHeaders=EXPR` | overrides `traefik.frontend.headers.SSLProxyHeaders` |
|
| `traefik.<segment_name>.frontend.headers.SSLProxyHeaders=EXPR` | overrides `traefik.frontend.headers.SSLProxyHeaders` |
|
||||||
| `traefik.<segment_name>.frontend.headers.STSSeconds=315360000` | overrides `traefik.frontend.headers.STSSeconds` |
|
| `traefik.<segment_name>.frontend.headers.STSSeconds=315360000` | overrides `traefik.frontend.headers.STSSeconds` |
|
||||||
| `traefik.<segment_name>.frontend.headers.STSIncludeSubdomains=true` | overrides `traefik.frontend.headers.STSIncludeSubdomains` |
|
| `traefik.<segment_name>.frontend.headers.STSIncludeSubdomains=true` | overrides `traefik.frontend.headers.STSIncludeSubdomains` |
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package middlewares
|
package middlewares
|
||||||
|
|
||||||
//Middleware based on https://github.com/unrolled/secure
|
// Middleware based on https://github.com/unrolled/secure
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
|
@ -3,7 +3,9 @@ package consulcatalog
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/containous/flaeg"
|
||||||
"github.com/containous/traefik/provider/label"
|
"github.com/containous/traefik/provider/label"
|
||||||
"github.com/containous/traefik/types"
|
"github.com/containous/traefik/types"
|
||||||
"github.com/hashicorp/consul/api"
|
"github.com/hashicorp/consul/api"
|
||||||
|
@ -113,6 +115,266 @@ func TestProviderBuildConfiguration(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
desc: "when all labels are set",
|
||||||
|
nodes: []catalogUpdate{
|
||||||
|
{
|
||||||
|
Service: &serviceUpdate{
|
||||||
|
ServiceName: "test",
|
||||||
|
Attributes: []string{
|
||||||
|
label.TraefikBackend + "=foobar",
|
||||||
|
|
||||||
|
label.TraefikBackendCircuitBreakerExpression + "=NetworkErrorRatio() > 0.5",
|
||||||
|
label.TraefikBackendHealthCheckPath + "=/health",
|
||||||
|
label.TraefikBackendHealthCheckPort + "=880",
|
||||||
|
label.TraefikBackendHealthCheckInterval + "=6",
|
||||||
|
label.TraefikBackendHealthCheckHostname + "=foo.com",
|
||||||
|
label.TraefikBackendHealthCheckHeaders + "=Foo:bar || Bar:foo",
|
||||||
|
label.TraefikBackendLoadBalancerMethod + "=drr",
|
||||||
|
label.TraefikBackendLoadBalancerSticky + "=true",
|
||||||
|
label.TraefikBackendLoadBalancerStickiness + "=true",
|
||||||
|
label.TraefikBackendLoadBalancerStickinessCookieName + "=chocolate",
|
||||||
|
label.TraefikBackendMaxConnAmount + "=666",
|
||||||
|
label.TraefikBackendMaxConnExtractorFunc + "=client.ip",
|
||||||
|
label.TraefikBackendBufferingMaxResponseBodyBytes + "=10485760",
|
||||||
|
label.TraefikBackendBufferingMemResponseBodyBytes + "=2097152",
|
||||||
|
label.TraefikBackendBufferingMaxRequestBodyBytes + "=10485760",
|
||||||
|
label.TraefikBackendBufferingMemRequestBodyBytes + "=2097152",
|
||||||
|
label.TraefikBackendBufferingRetryExpression + "=IsNetworkError() && Attempts() <= 2",
|
||||||
|
|
||||||
|
label.TraefikFrontendAuthBasic + "=test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/,test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0",
|
||||||
|
label.TraefikFrontendEntryPoints + "=http,https",
|
||||||
|
label.TraefikFrontendPassHostHeader + "=true",
|
||||||
|
label.TraefikFrontendPassTLSCert + "=true",
|
||||||
|
label.TraefikFrontendPriority + "=666",
|
||||||
|
label.TraefikFrontendRedirectEntryPoint + "=https",
|
||||||
|
label.TraefikFrontendRedirectRegex + "=nope",
|
||||||
|
label.TraefikFrontendRedirectReplacement + "=nope",
|
||||||
|
label.TraefikFrontendRedirectPermanent + "=true",
|
||||||
|
label.TraefikFrontendRule + "=Host:traefik.io",
|
||||||
|
label.TraefikFrontendWhiteListSourceRange + "=10.10.10.10",
|
||||||
|
label.TraefikFrontendWhiteListUseXForwardedFor + "=true",
|
||||||
|
|
||||||
|
label.TraefikFrontendRequestHeaders + "=Access-Control-Allow-Methods:POST,GET,OPTIONS || Content-type: application/json; charset=utf-8",
|
||||||
|
label.TraefikFrontendResponseHeaders + "=Access-Control-Allow-Methods:POST,GET,OPTIONS || Content-type: application/json; charset=utf-8",
|
||||||
|
label.TraefikFrontendSSLProxyHeaders + "=Access-Control-Allow-Methods:POST,GET,OPTIONS || Content-type: application/json; charset=utf-8",
|
||||||
|
label.TraefikFrontendAllowedHosts + "=foo,bar,bor",
|
||||||
|
label.TraefikFrontendHostsProxyHeaders + "=foo,bar,bor",
|
||||||
|
label.TraefikFrontendSSLHost + "=foo",
|
||||||
|
label.TraefikFrontendCustomFrameOptionsValue + "=foo",
|
||||||
|
label.TraefikFrontendContentSecurityPolicy + "=foo",
|
||||||
|
label.TraefikFrontendPublicKey + "=foo",
|
||||||
|
label.TraefikFrontendReferrerPolicy + "=foo",
|
||||||
|
label.TraefikFrontendCustomBrowserXSSValue + "=foo",
|
||||||
|
label.TraefikFrontendSTSSeconds + "=666",
|
||||||
|
label.TraefikFrontendSSLForceHost + "=true",
|
||||||
|
label.TraefikFrontendSSLRedirect + "=true",
|
||||||
|
label.TraefikFrontendSSLTemporaryRedirect + "=true",
|
||||||
|
label.TraefikFrontendSTSIncludeSubdomains + "=true",
|
||||||
|
label.TraefikFrontendSTSPreload + "=true",
|
||||||
|
label.TraefikFrontendForceSTSHeader + "=true",
|
||||||
|
label.TraefikFrontendFrameDeny + "=true",
|
||||||
|
label.TraefikFrontendContentTypeNosniff + "=true",
|
||||||
|
label.TraefikFrontendBrowserXSSFilter + "=true",
|
||||||
|
label.TraefikFrontendIsDevelopment + "=true",
|
||||||
|
|
||||||
|
label.Prefix + label.BaseFrontendErrorPage + "foo." + label.SuffixErrorPageStatus + "=404",
|
||||||
|
label.Prefix + label.BaseFrontendErrorPage + "foo." + label.SuffixErrorPageBackend + "=foobar",
|
||||||
|
label.Prefix + label.BaseFrontendErrorPage + "foo." + label.SuffixErrorPageQuery + "=foo_query",
|
||||||
|
label.Prefix + label.BaseFrontendErrorPage + "bar." + label.SuffixErrorPageStatus + "=500,600",
|
||||||
|
label.Prefix + label.BaseFrontendErrorPage + "bar." + label.SuffixErrorPageBackend + "=foobar",
|
||||||
|
label.Prefix + label.BaseFrontendErrorPage + "bar." + label.SuffixErrorPageQuery + "=bar_query",
|
||||||
|
|
||||||
|
label.TraefikFrontendRateLimitExtractorFunc + "=client.ip",
|
||||||
|
label.Prefix + label.BaseFrontendRateLimit + "foo." + label.SuffixRateLimitPeriod + "=6",
|
||||||
|
label.Prefix + label.BaseFrontendRateLimit + "foo." + label.SuffixRateLimitAverage + "=12",
|
||||||
|
label.Prefix + label.BaseFrontendRateLimit + "foo." + label.SuffixRateLimitBurst + "=18",
|
||||||
|
label.Prefix + label.BaseFrontendRateLimit + "bar." + label.SuffixRateLimitPeriod + "=3",
|
||||||
|
label.Prefix + label.BaseFrontendRateLimit + "bar." + label.SuffixRateLimitAverage + "=6",
|
||||||
|
label.Prefix + label.BaseFrontendRateLimit + "bar." + label.SuffixRateLimitBurst + "=9",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Nodes: []*api.ServiceEntry{
|
||||||
|
{
|
||||||
|
Service: &api.AgentService{
|
||||||
|
Service: "test",
|
||||||
|
Address: "10.0.0.1",
|
||||||
|
Port: 80,
|
||||||
|
Tags: []string{
|
||||||
|
label.TraefikProtocol + "=https",
|
||||||
|
label.TraefikWeight + "=12",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Node: &api.Node{
|
||||||
|
Node: "localhost",
|
||||||
|
Address: "127.0.0.1",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Service: &api.AgentService{
|
||||||
|
Service: "test",
|
||||||
|
Address: "10.0.0.2",
|
||||||
|
Port: 80,
|
||||||
|
Tags: []string{
|
||||||
|
label.TraefikProtocol + "=https",
|
||||||
|
label.TraefikWeight + "=12",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Node: &api.Node{
|
||||||
|
Node: "localhost",
|
||||||
|
Address: "127.0.0.1",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
expectedFrontends: map[string]*types.Frontend{
|
||||||
|
"frontend-test": {
|
||||||
|
EntryPoints: []string{
|
||||||
|
"http",
|
||||||
|
"https",
|
||||||
|
},
|
||||||
|
Backend: "backend-test",
|
||||||
|
Routes: map[string]types.Route{
|
||||||
|
"route-host-test": {
|
||||||
|
Rule: "Host:traefik.io",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
PassHostHeader: true,
|
||||||
|
PassTLSCert: true,
|
||||||
|
Priority: 666,
|
||||||
|
BasicAuth: []string{
|
||||||
|
"test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/",
|
||||||
|
"test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0",
|
||||||
|
},
|
||||||
|
WhiteList: &types.WhiteList{
|
||||||
|
SourceRange: []string{
|
||||||
|
"10.10.10.10",
|
||||||
|
},
|
||||||
|
UseXForwardedFor: true,
|
||||||
|
},
|
||||||
|
Headers: &types.Headers{
|
||||||
|
CustomRequestHeaders: map[string]string{
|
||||||
|
"Access-Control-Allow-Methods": "POST,GET,OPTIONS",
|
||||||
|
"Content-Type": "application/json; charset=utf-8",
|
||||||
|
},
|
||||||
|
CustomResponseHeaders: map[string]string{
|
||||||
|
"Access-Control-Allow-Methods": "POST,GET,OPTIONS",
|
||||||
|
"Content-Type": "application/json; charset=utf-8",
|
||||||
|
},
|
||||||
|
AllowedHosts: []string{
|
||||||
|
"foo",
|
||||||
|
"bar",
|
||||||
|
"bor",
|
||||||
|
},
|
||||||
|
HostsProxyHeaders: []string{
|
||||||
|
"foo",
|
||||||
|
"bar",
|
||||||
|
"bor",
|
||||||
|
},
|
||||||
|
SSLRedirect: true,
|
||||||
|
SSLTemporaryRedirect: true,
|
||||||
|
SSLForceHost: true,
|
||||||
|
SSLHost: "foo",
|
||||||
|
SSLProxyHeaders: map[string]string{
|
||||||
|
"Access-Control-Allow-Methods": "POST,GET,OPTIONS",
|
||||||
|
"Content-Type": "application/json; charset=utf-8",
|
||||||
|
},
|
||||||
|
STSSeconds: 666,
|
||||||
|
STSIncludeSubdomains: true,
|
||||||
|
STSPreload: true,
|
||||||
|
ForceSTSHeader: true,
|
||||||
|
FrameDeny: true,
|
||||||
|
CustomFrameOptionsValue: "foo",
|
||||||
|
ContentTypeNosniff: true,
|
||||||
|
BrowserXSSFilter: true,
|
||||||
|
CustomBrowserXSSValue: "foo",
|
||||||
|
ContentSecurityPolicy: "foo",
|
||||||
|
PublicKey: "foo",
|
||||||
|
ReferrerPolicy: "foo",
|
||||||
|
IsDevelopment: true,
|
||||||
|
},
|
||||||
|
Errors: map[string]*types.ErrorPage{
|
||||||
|
"foo": {
|
||||||
|
Status: []string{"404"},
|
||||||
|
Query: "foo_query",
|
||||||
|
Backend: "backend-foobar",
|
||||||
|
},
|
||||||
|
"bar": {
|
||||||
|
Status: []string{"500", "600"},
|
||||||
|
Query: "bar_query",
|
||||||
|
Backend: "backend-foobar",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
RateLimit: &types.RateLimit{
|
||||||
|
ExtractorFunc: "client.ip",
|
||||||
|
RateSet: map[string]*types.Rate{
|
||||||
|
"foo": {
|
||||||
|
Period: flaeg.Duration(6 * time.Second),
|
||||||
|
Average: 12,
|
||||||
|
Burst: 18,
|
||||||
|
},
|
||||||
|
"bar": {
|
||||||
|
Period: flaeg.Duration(3 * time.Second),
|
||||||
|
Average: 6,
|
||||||
|
Burst: 9,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Redirect: &types.Redirect{
|
||||||
|
EntryPoint: "https",
|
||||||
|
Regex: "",
|
||||||
|
Replacement: "",
|
||||||
|
Permanent: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
expectedBackends: map[string]*types.Backend{
|
||||||
|
"backend-test": {
|
||||||
|
Servers: map[string]types.Server{
|
||||||
|
"test-0-N753CZ-JEP1SmRf5Wfe6S3-RuM": {
|
||||||
|
URL: "https://10.0.0.1:80",
|
||||||
|
Weight: 12,
|
||||||
|
},
|
||||||
|
"test-1-u4RAIw2K4-PDJh41dqqB4kM2wy0": {
|
||||||
|
URL: "https://10.0.0.2:80",
|
||||||
|
Weight: 12,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
CircuitBreaker: &types.CircuitBreaker{
|
||||||
|
Expression: "NetworkErrorRatio() > 0.5",
|
||||||
|
},
|
||||||
|
LoadBalancer: &types.LoadBalancer{
|
||||||
|
Method: "drr",
|
||||||
|
Sticky: true,
|
||||||
|
Stickiness: &types.Stickiness{
|
||||||
|
CookieName: "chocolate",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
MaxConn: &types.MaxConn{
|
||||||
|
Amount: 666,
|
||||||
|
ExtractorFunc: "client.ip",
|
||||||
|
},
|
||||||
|
HealthCheck: &types.HealthCheck{
|
||||||
|
Path: "/health",
|
||||||
|
Port: 880,
|
||||||
|
Interval: "6",
|
||||||
|
Hostname: "foo.com",
|
||||||
|
Headers: map[string]string{
|
||||||
|
"Foo": "bar",
|
||||||
|
"Bar": "foo",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Buffering: &types.Buffering{
|
||||||
|
MaxResponseBodyBytes: 10485760,
|
||||||
|
MemResponseBodyBytes: 2097152,
|
||||||
|
MaxRequestBodyBytes: 10485760,
|
||||||
|
MemRequestBodyBytes: 2097152,
|
||||||
|
RetryExpression: "IsNetworkError() && Attempts() <= 2",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range testCases {
|
for _, test := range testCases {
|
||||||
|
|
|
@ -140,6 +140,7 @@ func TestDockerBuildConfiguration(t *testing.T) {
|
||||||
label.TraefikFrontendReferrerPolicy: "foo",
|
label.TraefikFrontendReferrerPolicy: "foo",
|
||||||
label.TraefikFrontendCustomBrowserXSSValue: "foo",
|
label.TraefikFrontendCustomBrowserXSSValue: "foo",
|
||||||
label.TraefikFrontendSTSSeconds: "666",
|
label.TraefikFrontendSTSSeconds: "666",
|
||||||
|
label.TraefikFrontendSSLForceHost: "true",
|
||||||
label.TraefikFrontendSSLRedirect: "true",
|
label.TraefikFrontendSSLRedirect: "true",
|
||||||
label.TraefikFrontendSSLTemporaryRedirect: "true",
|
label.TraefikFrontendSSLTemporaryRedirect: "true",
|
||||||
label.TraefikFrontendSTSIncludeSubdomains: "true",
|
label.TraefikFrontendSTSIncludeSubdomains: "true",
|
||||||
|
@ -216,6 +217,7 @@ func TestDockerBuildConfiguration(t *testing.T) {
|
||||||
SSLRedirect: true,
|
SSLRedirect: true,
|
||||||
SSLTemporaryRedirect: true,
|
SSLTemporaryRedirect: true,
|
||||||
SSLHost: "foo",
|
SSLHost: "foo",
|
||||||
|
SSLForceHost: true,
|
||||||
SSLProxyHeaders: map[string]string{
|
SSLProxyHeaders: map[string]string{
|
||||||
"Access-Control-Allow-Methods": "POST,GET,OPTIONS",
|
"Access-Control-Allow-Methods": "POST,GET,OPTIONS",
|
||||||
"Content-Type": "application/json; charset=utf-8",
|
"Content-Type": "application/json; charset=utf-8",
|
||||||
|
|
|
@ -148,6 +148,7 @@ func TestSwarmBuildConfiguration(t *testing.T) {
|
||||||
label.TraefikFrontendReferrerPolicy: "foo",
|
label.TraefikFrontendReferrerPolicy: "foo",
|
||||||
label.TraefikFrontendCustomBrowserXSSValue: "foo",
|
label.TraefikFrontendCustomBrowserXSSValue: "foo",
|
||||||
label.TraefikFrontendSTSSeconds: "666",
|
label.TraefikFrontendSTSSeconds: "666",
|
||||||
|
label.TraefikFrontendSSLForceHost: "true",
|
||||||
label.TraefikFrontendSSLRedirect: "true",
|
label.TraefikFrontendSSLRedirect: "true",
|
||||||
label.TraefikFrontendSSLTemporaryRedirect: "true",
|
label.TraefikFrontendSSLTemporaryRedirect: "true",
|
||||||
label.TraefikFrontendSTSIncludeSubdomains: "true",
|
label.TraefikFrontendSTSIncludeSubdomains: "true",
|
||||||
|
@ -221,6 +222,7 @@ func TestSwarmBuildConfiguration(t *testing.T) {
|
||||||
},
|
},
|
||||||
SSLRedirect: true,
|
SSLRedirect: true,
|
||||||
SSLTemporaryRedirect: true,
|
SSLTemporaryRedirect: true,
|
||||||
|
SSLForceHost: true,
|
||||||
SSLHost: "foo",
|
SSLHost: "foo",
|
||||||
SSLProxyHeaders: map[string]string{
|
SSLProxyHeaders: map[string]string{
|
||||||
"Access-Control-Allow-Methods": "POST,GET,OPTIONS",
|
"Access-Control-Allow-Methods": "POST,GET,OPTIONS",
|
||||||
|
|
|
@ -100,6 +100,7 @@ func TestSegmentBuildConfiguration(t *testing.T) {
|
||||||
label.Prefix + "sauternes." + label.SuffixFrontendHeadersReferrerPolicy: "foo",
|
label.Prefix + "sauternes." + label.SuffixFrontendHeadersReferrerPolicy: "foo",
|
||||||
label.Prefix + "sauternes." + label.SuffixFrontendHeadersCustomBrowserXSSValue: "foo",
|
label.Prefix + "sauternes." + label.SuffixFrontendHeadersCustomBrowserXSSValue: "foo",
|
||||||
label.Prefix + "sauternes." + label.SuffixFrontendHeadersSTSSeconds: "666",
|
label.Prefix + "sauternes." + label.SuffixFrontendHeadersSTSSeconds: "666",
|
||||||
|
label.Prefix + "sauternes." + label.SuffixFrontendHeadersSSLForceHost: "true",
|
||||||
label.Prefix + "sauternes." + label.SuffixFrontendHeadersSSLRedirect: "true",
|
label.Prefix + "sauternes." + label.SuffixFrontendHeadersSSLRedirect: "true",
|
||||||
label.Prefix + "sauternes." + label.SuffixFrontendHeadersSSLTemporaryRedirect: "true",
|
label.Prefix + "sauternes." + label.SuffixFrontendHeadersSSLTemporaryRedirect: "true",
|
||||||
label.Prefix + "sauternes." + label.SuffixFrontendHeadersSTSIncludeSubdomains: "true",
|
label.Prefix + "sauternes." + label.SuffixFrontendHeadersSTSIncludeSubdomains: "true",
|
||||||
|
@ -170,6 +171,7 @@ func TestSegmentBuildConfiguration(t *testing.T) {
|
||||||
},
|
},
|
||||||
SSLRedirect: true,
|
SSLRedirect: true,
|
||||||
SSLTemporaryRedirect: true,
|
SSLTemporaryRedirect: true,
|
||||||
|
SSLForceHost: true,
|
||||||
SSLHost: "foo",
|
SSLHost: "foo",
|
||||||
SSLProxyHeaders: map[string]string{
|
SSLProxyHeaders: map[string]string{
|
||||||
"Access-Control-Allow-Methods": "POST,GET,OPTIONS",
|
"Access-Control-Allow-Methods": "POST,GET,OPTIONS",
|
||||||
|
|
|
@ -175,6 +175,7 @@ func TestBuildConfiguration(t *testing.T) {
|
||||||
label.TraefikFrontendReferrerPolicy: aws.String("foo"),
|
label.TraefikFrontendReferrerPolicy: aws.String("foo"),
|
||||||
label.TraefikFrontendCustomBrowserXSSValue: aws.String("foo"),
|
label.TraefikFrontendCustomBrowserXSSValue: aws.String("foo"),
|
||||||
label.TraefikFrontendSTSSeconds: aws.String("666"),
|
label.TraefikFrontendSTSSeconds: aws.String("666"),
|
||||||
|
label.TraefikFrontendSSLForceHost: aws.String("true"),
|
||||||
label.TraefikFrontendSSLRedirect: aws.String("true"),
|
label.TraefikFrontendSSLRedirect: aws.String("true"),
|
||||||
label.TraefikFrontendSSLTemporaryRedirect: aws.String("true"),
|
label.TraefikFrontendSSLTemporaryRedirect: aws.String("true"),
|
||||||
label.TraefikFrontendSTSIncludeSubdomains: aws.String("true"),
|
label.TraefikFrontendSTSIncludeSubdomains: aws.String("true"),
|
||||||
|
@ -294,6 +295,7 @@ func TestBuildConfiguration(t *testing.T) {
|
||||||
},
|
},
|
||||||
SSLRedirect: true,
|
SSLRedirect: true,
|
||||||
SSLTemporaryRedirect: true,
|
SSLTemporaryRedirect: true,
|
||||||
|
SSLForceHost: true,
|
||||||
SSLHost: "foo",
|
SSLHost: "foo",
|
||||||
SSLProxyHeaders: map[string]string{
|
SSLProxyHeaders: map[string]string{
|
||||||
"Access-Control-Allow-Methods": "POST,GET,OPTIONS",
|
"Access-Control-Allow-Methods": "POST,GET,OPTIONS",
|
||||||
|
|
|
@ -32,6 +32,7 @@ const (
|
||||||
annotationKubernetesBuffering = "ingress.kubernetes.io/buffering"
|
annotationKubernetesBuffering = "ingress.kubernetes.io/buffering"
|
||||||
annotationKubernetesAppRoot = "ingress.kubernetes.io/app-root"
|
annotationKubernetesAppRoot = "ingress.kubernetes.io/app-root"
|
||||||
|
|
||||||
|
annotationKubernetesSSLForceHost = "ingress.kubernetes.io/ssl-force-host"
|
||||||
annotationKubernetesSSLRedirect = "ingress.kubernetes.io/ssl-redirect"
|
annotationKubernetesSSLRedirect = "ingress.kubernetes.io/ssl-redirect"
|
||||||
annotationKubernetesHSTSMaxAge = "ingress.kubernetes.io/hsts-max-age"
|
annotationKubernetesHSTSMaxAge = "ingress.kubernetes.io/hsts-max-age"
|
||||||
annotationKubernetesHSTSIncludeSubdomains = "ingress.kubernetes.io/hsts-include-subdomains"
|
annotationKubernetesHSTSIncludeSubdomains = "ingress.kubernetes.io/hsts-include-subdomains"
|
||||||
|
|
|
@ -599,6 +599,7 @@ func getHeader(i *extensionsv1beta1.Ingress) *types.Headers {
|
||||||
CustomResponseHeaders: getMapValue(i.Annotations, annotationKubernetesCustomResponseHeaders),
|
CustomResponseHeaders: getMapValue(i.Annotations, annotationKubernetesCustomResponseHeaders),
|
||||||
AllowedHosts: getSliceStringValue(i.Annotations, annotationKubernetesAllowedHosts),
|
AllowedHosts: getSliceStringValue(i.Annotations, annotationKubernetesAllowedHosts),
|
||||||
HostsProxyHeaders: getSliceStringValue(i.Annotations, annotationKubernetesProxyHeaders),
|
HostsProxyHeaders: getSliceStringValue(i.Annotations, annotationKubernetesProxyHeaders),
|
||||||
|
SSLForceHost: getBoolValue(i.Annotations, annotationKubernetesSSLForceHost, false),
|
||||||
SSLRedirect: getBoolValue(i.Annotations, annotationKubernetesSSLRedirect, false),
|
SSLRedirect: getBoolValue(i.Annotations, annotationKubernetesSSLRedirect, false),
|
||||||
SSLTemporaryRedirect: getBoolValue(i.Annotations, annotationKubernetesSSLTemporaryRedirect, false),
|
SSLTemporaryRedirect: getBoolValue(i.Annotations, annotationKubernetesSSLTemporaryRedirect, false),
|
||||||
SSLHost: getStringValue(i.Annotations, annotationKubernetesSSLHost, ""),
|
SSLHost: getStringValue(i.Annotations, annotationKubernetesSSLHost, ""),
|
||||||
|
|
|
@ -786,6 +786,7 @@ rateset:
|
||||||
iAnnotation(annotationKubernetesAllowedHosts, "foo, fii, fuu"),
|
iAnnotation(annotationKubernetesAllowedHosts, "foo, fii, fuu"),
|
||||||
iAnnotation(annotationKubernetesProxyHeaders, "foo, fii, fuu"),
|
iAnnotation(annotationKubernetesProxyHeaders, "foo, fii, fuu"),
|
||||||
iAnnotation(annotationKubernetesHSTSMaxAge, "666"),
|
iAnnotation(annotationKubernetesHSTSMaxAge, "666"),
|
||||||
|
iAnnotation(annotationKubernetesSSLForceHost, "true"),
|
||||||
iAnnotation(annotationKubernetesSSLRedirect, "true"),
|
iAnnotation(annotationKubernetesSSLRedirect, "true"),
|
||||||
iAnnotation(annotationKubernetesSSLTemporaryRedirect, "true"),
|
iAnnotation(annotationKubernetesSSLTemporaryRedirect, "true"),
|
||||||
iAnnotation(annotationKubernetesHSTSIncludeSubdomains, "true"),
|
iAnnotation(annotationKubernetesHSTSIncludeSubdomains, "true"),
|
||||||
|
@ -1030,6 +1031,7 @@ rateset:
|
||||||
AllowedHosts: []string{"foo", "fii", "fuu"},
|
AllowedHosts: []string{"foo", "fii", "fuu"},
|
||||||
HostsProxyHeaders: []string{"foo", "fii", "fuu"},
|
HostsProxyHeaders: []string{"foo", "fii", "fuu"},
|
||||||
STSSeconds: 666,
|
STSSeconds: 666,
|
||||||
|
SSLForceHost: true,
|
||||||
SSLRedirect: true,
|
SSLRedirect: true,
|
||||||
SSLTemporaryRedirect: true,
|
SSLTemporaryRedirect: true,
|
||||||
STSIncludeSubdomains: true,
|
STSIncludeSubdomains: true,
|
||||||
|
|
|
@ -53,6 +53,7 @@ const (
|
||||||
pathFrontendCustomResponseHeaders = "/headers/customresponseheaders/"
|
pathFrontendCustomResponseHeaders = "/headers/customresponseheaders/"
|
||||||
pathFrontendAllowedHosts = "/headers/allowedhosts"
|
pathFrontendAllowedHosts = "/headers/allowedhosts"
|
||||||
pathFrontendHostsProxyHeaders = "/headers/hostsproxyheaders"
|
pathFrontendHostsProxyHeaders = "/headers/hostsproxyheaders"
|
||||||
|
pathFrontendSSLForceHost = "/headers/sslforcehost"
|
||||||
pathFrontendSSLRedirect = "/headers/sslredirect"
|
pathFrontendSSLRedirect = "/headers/sslredirect"
|
||||||
pathFrontendSSLTemporaryRedirect = "/headers/ssltemporaryredirect"
|
pathFrontendSSLTemporaryRedirect = "/headers/ssltemporaryredirect"
|
||||||
pathFrontendSSLHost = "/headers/sslhost"
|
pathFrontendSSLHost = "/headers/sslhost"
|
||||||
|
|
|
@ -226,6 +226,7 @@ func (p *Provider) getHeaders(rootPath string) *types.Headers {
|
||||||
SSLProxyHeaders: p.getMap(rootPath, pathFrontendSSLProxyHeaders),
|
SSLProxyHeaders: p.getMap(rootPath, pathFrontendSSLProxyHeaders),
|
||||||
AllowedHosts: p.getList("", rootPath, pathFrontendAllowedHosts),
|
AllowedHosts: p.getList("", rootPath, pathFrontendAllowedHosts),
|
||||||
HostsProxyHeaders: p.getList(rootPath, pathFrontendHostsProxyHeaders),
|
HostsProxyHeaders: p.getList(rootPath, pathFrontendHostsProxyHeaders),
|
||||||
|
SSLForceHost: p.getBool(false, rootPath, pathFrontendSSLForceHost),
|
||||||
SSLRedirect: p.getBool(false, rootPath, pathFrontendSSLRedirect),
|
SSLRedirect: p.getBool(false, rootPath, pathFrontendSSLRedirect),
|
||||||
SSLTemporaryRedirect: p.getBool(false, rootPath, pathFrontendSSLTemporaryRedirect),
|
SSLTemporaryRedirect: p.getBool(false, rootPath, pathFrontendSSLTemporaryRedirect),
|
||||||
SSLHost: p.get("", rootPath, pathFrontendSSLHost),
|
SSLHost: p.get("", rootPath, pathFrontendSSLHost),
|
||||||
|
|
|
@ -121,6 +121,7 @@ func TestProviderBuildConfiguration(t *testing.T) {
|
||||||
withPair(pathFrontendPublicKey, "foo"),
|
withPair(pathFrontendPublicKey, "foo"),
|
||||||
withPair(pathFrontendReferrerPolicy, "foo"),
|
withPair(pathFrontendReferrerPolicy, "foo"),
|
||||||
withPair(pathFrontendCustomBrowserXSSValue, "foo"),
|
withPair(pathFrontendCustomBrowserXSSValue, "foo"),
|
||||||
|
withPair(pathFrontendSSLForceHost, "true"),
|
||||||
withPair(pathFrontendSSLRedirect, "true"),
|
withPair(pathFrontendSSLRedirect, "true"),
|
||||||
withPair(pathFrontendSSLTemporaryRedirect, "true"),
|
withPair(pathFrontendSSLTemporaryRedirect, "true"),
|
||||||
withPair(pathFrontendSTSIncludeSubdomains, "true"),
|
withPair(pathFrontendSTSIncludeSubdomains, "true"),
|
||||||
|
@ -254,6 +255,7 @@ func TestProviderBuildConfiguration(t *testing.T) {
|
||||||
PublicKey: "foo",
|
PublicKey: "foo",
|
||||||
ReferrerPolicy: "foo",
|
ReferrerPolicy: "foo",
|
||||||
CustomBrowserXSSValue: "foo",
|
CustomBrowserXSSValue: "foo",
|
||||||
|
SSLForceHost: true,
|
||||||
SSLRedirect: true,
|
SSLRedirect: true,
|
||||||
SSLTemporaryRedirect: true,
|
SSLTemporaryRedirect: true,
|
||||||
STSIncludeSubdomains: true,
|
STSIncludeSubdomains: true,
|
||||||
|
|
|
@ -41,6 +41,7 @@ const (
|
||||||
SuffixFrontendResponseHeaders = SuffixFrontendHeaders + "customResponseHeaders"
|
SuffixFrontendResponseHeaders = SuffixFrontendHeaders + "customResponseHeaders"
|
||||||
SuffixFrontendHeadersAllowedHosts = SuffixFrontendHeaders + "allowedHosts"
|
SuffixFrontendHeadersAllowedHosts = SuffixFrontendHeaders + "allowedHosts"
|
||||||
SuffixFrontendHeadersHostsProxyHeaders = SuffixFrontendHeaders + "hostsProxyHeaders"
|
SuffixFrontendHeadersHostsProxyHeaders = SuffixFrontendHeaders + "hostsProxyHeaders"
|
||||||
|
SuffixFrontendHeadersSSLForceHost = SuffixFrontendHeaders + "SSLForceHost"
|
||||||
SuffixFrontendHeadersSSLRedirect = SuffixFrontendHeaders + "SSLRedirect"
|
SuffixFrontendHeadersSSLRedirect = SuffixFrontendHeaders + "SSLRedirect"
|
||||||
SuffixFrontendHeadersSSLTemporaryRedirect = SuffixFrontendHeaders + "SSLTemporaryRedirect"
|
SuffixFrontendHeadersSSLTemporaryRedirect = SuffixFrontendHeaders + "SSLTemporaryRedirect"
|
||||||
SuffixFrontendHeadersSSLHost = SuffixFrontendHeaders + "SSLHost"
|
SuffixFrontendHeadersSSLHost = SuffixFrontendHeaders + "SSLHost"
|
||||||
|
@ -120,6 +121,7 @@ const (
|
||||||
TraefikFrontendResponseHeaders = Prefix + SuffixFrontendResponseHeaders
|
TraefikFrontendResponseHeaders = Prefix + SuffixFrontendResponseHeaders
|
||||||
TraefikFrontendAllowedHosts = Prefix + SuffixFrontendHeadersAllowedHosts
|
TraefikFrontendAllowedHosts = Prefix + SuffixFrontendHeadersAllowedHosts
|
||||||
TraefikFrontendHostsProxyHeaders = Prefix + SuffixFrontendHeadersHostsProxyHeaders
|
TraefikFrontendHostsProxyHeaders = Prefix + SuffixFrontendHeadersHostsProxyHeaders
|
||||||
|
TraefikFrontendSSLForceHost = Prefix + SuffixFrontendHeadersSSLForceHost
|
||||||
TraefikFrontendSSLRedirect = Prefix + SuffixFrontendHeadersSSLRedirect
|
TraefikFrontendSSLRedirect = Prefix + SuffixFrontendHeadersSSLRedirect
|
||||||
TraefikFrontendSSLTemporaryRedirect = Prefix + SuffixFrontendHeadersSSLTemporaryRedirect
|
TraefikFrontendSSLTemporaryRedirect = Prefix + SuffixFrontendHeadersSSLTemporaryRedirect
|
||||||
TraefikFrontendSSLHost = Prefix + SuffixFrontendHeadersSSLHost
|
TraefikFrontendSSLHost = Prefix + SuffixFrontendHeadersSSLHost
|
||||||
|
|
|
@ -190,6 +190,7 @@ func GetHeaders(labels map[string]string) *types.Headers {
|
||||||
STSSeconds: GetInt64Value(labels, TraefikFrontendSTSSeconds, 0),
|
STSSeconds: GetInt64Value(labels, TraefikFrontendSTSSeconds, 0),
|
||||||
SSLRedirect: GetBoolValue(labels, TraefikFrontendSSLRedirect, false),
|
SSLRedirect: GetBoolValue(labels, TraefikFrontendSSLRedirect, false),
|
||||||
SSLTemporaryRedirect: GetBoolValue(labels, TraefikFrontendSSLTemporaryRedirect, false),
|
SSLTemporaryRedirect: GetBoolValue(labels, TraefikFrontendSSLTemporaryRedirect, false),
|
||||||
|
SSLForceHost: GetBoolValue(labels, TraefikFrontendSSLForceHost, false),
|
||||||
STSIncludeSubdomains: GetBoolValue(labels, TraefikFrontendSTSIncludeSubdomains, false),
|
STSIncludeSubdomains: GetBoolValue(labels, TraefikFrontendSTSIncludeSubdomains, false),
|
||||||
STSPreload: GetBoolValue(labels, TraefikFrontendSTSPreload, false),
|
STSPreload: GetBoolValue(labels, TraefikFrontendSTSPreload, false),
|
||||||
ForceSTSHeader: GetBoolValue(labels, TraefikFrontendForceSTSHeader, false),
|
ForceSTSHeader: GetBoolValue(labels, TraefikFrontendForceSTSHeader, false),
|
||||||
|
|
|
@ -606,6 +606,7 @@ func TestGetHeaders(t *testing.T) {
|
||||||
TraefikFrontendCustomBrowserXSSValue: "foo",
|
TraefikFrontendCustomBrowserXSSValue: "foo",
|
||||||
TraefikFrontendSTSSeconds: "666",
|
TraefikFrontendSTSSeconds: "666",
|
||||||
TraefikFrontendSSLRedirect: "true",
|
TraefikFrontendSSLRedirect: "true",
|
||||||
|
TraefikFrontendSSLForceHost: "true",
|
||||||
TraefikFrontendSSLTemporaryRedirect: "true",
|
TraefikFrontendSSLTemporaryRedirect: "true",
|
||||||
TraefikFrontendSTSIncludeSubdomains: "true",
|
TraefikFrontendSTSIncludeSubdomains: "true",
|
||||||
TraefikFrontendSTSPreload: "true",
|
TraefikFrontendSTSPreload: "true",
|
||||||
|
@ -637,6 +638,7 @@ func TestGetHeaders(t *testing.T) {
|
||||||
ReferrerPolicy: "foo",
|
ReferrerPolicy: "foo",
|
||||||
CustomBrowserXSSValue: "foo",
|
CustomBrowserXSSValue: "foo",
|
||||||
STSSeconds: 666,
|
STSSeconds: 666,
|
||||||
|
SSLForceHost: true,
|
||||||
SSLRedirect: true,
|
SSLRedirect: true,
|
||||||
SSLTemporaryRedirect: true,
|
SSLTemporaryRedirect: true,
|
||||||
STSIncludeSubdomains: true,
|
STSIncludeSubdomains: true,
|
||||||
|
|
|
@ -209,6 +209,7 @@ func TestBuildConfiguration(t *testing.T) {
|
||||||
withLabel(label.TraefikFrontendSSLProxyHeaders, "Access-Control-Allow-Methods:POST,GET,OPTIONS || Content-type: application/json; charset=utf-8"),
|
withLabel(label.TraefikFrontendSSLProxyHeaders, "Access-Control-Allow-Methods:POST,GET,OPTIONS || Content-type: application/json; charset=utf-8"),
|
||||||
withLabel(label.TraefikFrontendAllowedHosts, "foo,bar,bor"),
|
withLabel(label.TraefikFrontendAllowedHosts, "foo,bar,bor"),
|
||||||
withLabel(label.TraefikFrontendHostsProxyHeaders, "foo,bar,bor"),
|
withLabel(label.TraefikFrontendHostsProxyHeaders, "foo,bar,bor"),
|
||||||
|
withLabel(label.TraefikFrontendSSLForceHost, "true"),
|
||||||
withLabel(label.TraefikFrontendSSLHost, "foo"),
|
withLabel(label.TraefikFrontendSSLHost, "foo"),
|
||||||
withLabel(label.TraefikFrontendCustomFrameOptionsValue, "foo"),
|
withLabel(label.TraefikFrontendCustomFrameOptionsValue, "foo"),
|
||||||
withLabel(label.TraefikFrontendContentSecurityPolicy, "foo"),
|
withLabel(label.TraefikFrontendContentSecurityPolicy, "foo"),
|
||||||
|
@ -285,6 +286,7 @@ func TestBuildConfiguration(t *testing.T) {
|
||||||
},
|
},
|
||||||
SSLRedirect: true,
|
SSLRedirect: true,
|
||||||
SSLTemporaryRedirect: true,
|
SSLTemporaryRedirect: true,
|
||||||
|
SSLForceHost: true,
|
||||||
SSLHost: "foo",
|
SSLHost: "foo",
|
||||||
SSLProxyHeaders: map[string]string{
|
SSLProxyHeaders: map[string]string{
|
||||||
"Access-Control-Allow-Methods": "POST,GET,OPTIONS",
|
"Access-Control-Allow-Methods": "POST,GET,OPTIONS",
|
||||||
|
@ -581,6 +583,7 @@ func TestBuildConfigurationSegments(t *testing.T) {
|
||||||
withSegmentLabel(label.TraefikFrontendSSLProxyHeaders, "Access-Control-Allow-Methods:POST,GET,OPTIONS || Content-type: application/json; charset=utf-8", "containous"),
|
withSegmentLabel(label.TraefikFrontendSSLProxyHeaders, "Access-Control-Allow-Methods:POST,GET,OPTIONS || Content-type: application/json; charset=utf-8", "containous"),
|
||||||
withSegmentLabel(label.TraefikFrontendAllowedHosts, "foo,bar,bor", "containous"),
|
withSegmentLabel(label.TraefikFrontendAllowedHosts, "foo,bar,bor", "containous"),
|
||||||
withSegmentLabel(label.TraefikFrontendHostsProxyHeaders, "foo,bar,bor", "containous"),
|
withSegmentLabel(label.TraefikFrontendHostsProxyHeaders, "foo,bar,bor", "containous"),
|
||||||
|
withSegmentLabel(label.TraefikFrontendSSLForceHost, "true", "containous"),
|
||||||
withSegmentLabel(label.TraefikFrontendSSLHost, "foo", "containous"),
|
withSegmentLabel(label.TraefikFrontendSSLHost, "foo", "containous"),
|
||||||
withSegmentLabel(label.TraefikFrontendCustomFrameOptionsValue, "foo", "containous"),
|
withSegmentLabel(label.TraefikFrontendCustomFrameOptionsValue, "foo", "containous"),
|
||||||
withSegmentLabel(label.TraefikFrontendContentSecurityPolicy, "foo", "containous"),
|
withSegmentLabel(label.TraefikFrontendContentSecurityPolicy, "foo", "containous"),
|
||||||
|
@ -657,6 +660,7 @@ func TestBuildConfigurationSegments(t *testing.T) {
|
||||||
},
|
},
|
||||||
SSLRedirect: true,
|
SSLRedirect: true,
|
||||||
SSLTemporaryRedirect: true,
|
SSLTemporaryRedirect: true,
|
||||||
|
SSLForceHost: true,
|
||||||
SSLHost: "foo",
|
SSLHost: "foo",
|
||||||
SSLProxyHeaders: map[string]string{
|
SSLProxyHeaders: map[string]string{
|
||||||
"Access-Control-Allow-Methods": "POST,GET,OPTIONS",
|
"Access-Control-Allow-Methods": "POST,GET,OPTIONS",
|
||||||
|
|
|
@ -158,6 +158,7 @@ func TestBuildConfiguration(t *testing.T) {
|
||||||
withLabel(label.TraefikFrontendSSLProxyHeaders, "Access-Control-Allow-Methods:POST,GET,OPTIONS || Content-type:application/json; charset=utf-8"),
|
withLabel(label.TraefikFrontendSSLProxyHeaders, "Access-Control-Allow-Methods:POST,GET,OPTIONS || Content-type:application/json; charset=utf-8"),
|
||||||
withLabel(label.TraefikFrontendAllowedHosts, "foo,bar,bor"),
|
withLabel(label.TraefikFrontendAllowedHosts, "foo,bar,bor"),
|
||||||
withLabel(label.TraefikFrontendHostsProxyHeaders, "foo,bar,bor"),
|
withLabel(label.TraefikFrontendHostsProxyHeaders, "foo,bar,bor"),
|
||||||
|
withLabel(label.TraefikFrontendSSLForceHost, "true"),
|
||||||
withLabel(label.TraefikFrontendSSLHost, "foo"),
|
withLabel(label.TraefikFrontendSSLHost, "foo"),
|
||||||
withLabel(label.TraefikFrontendCustomFrameOptionsValue, "foo"),
|
withLabel(label.TraefikFrontendCustomFrameOptionsValue, "foo"),
|
||||||
withLabel(label.TraefikFrontendContentSecurityPolicy, "foo"),
|
withLabel(label.TraefikFrontendContentSecurityPolicy, "foo"),
|
||||||
|
@ -240,6 +241,7 @@ func TestBuildConfiguration(t *testing.T) {
|
||||||
},
|
},
|
||||||
SSLRedirect: true,
|
SSLRedirect: true,
|
||||||
SSLTemporaryRedirect: true,
|
SSLTemporaryRedirect: true,
|
||||||
|
SSLForceHost: true,
|
||||||
SSLHost: "foo",
|
SSLHost: "foo",
|
||||||
SSLProxyHeaders: map[string]string{
|
SSLProxyHeaders: map[string]string{
|
||||||
"Access-Control-Allow-Methods": "POST,GET,OPTIONS",
|
"Access-Control-Allow-Methods": "POST,GET,OPTIONS",
|
||||||
|
|
|
@ -83,6 +83,7 @@ func TestProviderBuildConfiguration(t *testing.T) {
|
||||||
label.TraefikFrontendReferrerPolicy: "foo",
|
label.TraefikFrontendReferrerPolicy: "foo",
|
||||||
label.TraefikFrontendCustomBrowserXSSValue: "foo",
|
label.TraefikFrontendCustomBrowserXSSValue: "foo",
|
||||||
label.TraefikFrontendSTSSeconds: "666",
|
label.TraefikFrontendSTSSeconds: "666",
|
||||||
|
label.TraefikFrontendSSLForceHost: "true",
|
||||||
label.TraefikFrontendSSLRedirect: "true",
|
label.TraefikFrontendSSLRedirect: "true",
|
||||||
label.TraefikFrontendSSLTemporaryRedirect: "true",
|
label.TraefikFrontendSSLTemporaryRedirect: "true",
|
||||||
label.TraefikFrontendSTSIncludeSubdomains: "true",
|
label.TraefikFrontendSTSIncludeSubdomains: "true",
|
||||||
|
@ -158,6 +159,7 @@ func TestProviderBuildConfiguration(t *testing.T) {
|
||||||
},
|
},
|
||||||
SSLRedirect: true,
|
SSLRedirect: true,
|
||||||
SSLTemporaryRedirect: true,
|
SSLTemporaryRedirect: true,
|
||||||
|
SSLForceHost: true,
|
||||||
SSLHost: "foo",
|
SSLHost: "foo",
|
||||||
SSLProxyHeaders: map[string]string{
|
SSLProxyHeaders: map[string]string{
|
||||||
"Access-Control-Allow-Methods": "POST,GET,OPTIONS",
|
"Access-Control-Allow-Methods": "POST,GET,OPTIONS",
|
||||||
|
@ -292,6 +294,7 @@ func TestProviderBuildConfiguration(t *testing.T) {
|
||||||
label.Prefix + "sauternes." + label.SuffixFrontendHeadersReferrerPolicy: "foo",
|
label.Prefix + "sauternes." + label.SuffixFrontendHeadersReferrerPolicy: "foo",
|
||||||
label.Prefix + "sauternes." + label.SuffixFrontendHeadersCustomBrowserXSSValue: "foo",
|
label.Prefix + "sauternes." + label.SuffixFrontendHeadersCustomBrowserXSSValue: "foo",
|
||||||
label.Prefix + "sauternes." + label.SuffixFrontendHeadersSTSSeconds: "666",
|
label.Prefix + "sauternes." + label.SuffixFrontendHeadersSTSSeconds: "666",
|
||||||
|
label.Prefix + "sauternes." + label.SuffixFrontendHeadersSSLForceHost: "true",
|
||||||
label.Prefix + "sauternes." + label.SuffixFrontendHeadersSSLRedirect: "true",
|
label.Prefix + "sauternes." + label.SuffixFrontendHeadersSSLRedirect: "true",
|
||||||
label.Prefix + "sauternes." + label.SuffixFrontendHeadersSSLTemporaryRedirect: "true",
|
label.Prefix + "sauternes." + label.SuffixFrontendHeadersSSLTemporaryRedirect: "true",
|
||||||
label.Prefix + "sauternes." + label.SuffixFrontendHeadersSTSIncludeSubdomains: "true",
|
label.Prefix + "sauternes." + label.SuffixFrontendHeadersSTSIncludeSubdomains: "true",
|
||||||
|
@ -356,6 +359,7 @@ func TestProviderBuildConfiguration(t *testing.T) {
|
||||||
HostsProxyHeaders: []string{"foo", "bar", "bor"},
|
HostsProxyHeaders: []string{"foo", "bar", "bor"},
|
||||||
SSLRedirect: true,
|
SSLRedirect: true,
|
||||||
SSLTemporaryRedirect: true,
|
SSLTemporaryRedirect: true,
|
||||||
|
SSLForceHost: true,
|
||||||
SSLHost: "foo",
|
SSLHost: "foo",
|
||||||
SSLProxyHeaders: map[string]string{
|
SSLProxyHeaders: map[string]string{
|
||||||
"Access-Control-Allow-Methods": "POST,GET,OPTIONS",
|
"Access-Control-Allow-Methods": "POST,GET,OPTIONS",
|
||||||
|
|
|
@ -127,6 +127,7 @@
|
||||||
SSLRedirect = {{ $headers.SSLRedirect }}
|
SSLRedirect = {{ $headers.SSLRedirect }}
|
||||||
SSLTemporaryRedirect = {{ $headers.SSLTemporaryRedirect }}
|
SSLTemporaryRedirect = {{ $headers.SSLTemporaryRedirect }}
|
||||||
SSLHost = "{{ $headers.SSLHost }}"
|
SSLHost = "{{ $headers.SSLHost }}"
|
||||||
|
SSLForceHost = {{ $headers.SSLForceHost }}
|
||||||
STSSeconds = {{ $headers.STSSeconds }}
|
STSSeconds = {{ $headers.STSSeconds }}
|
||||||
STSIncludeSubdomains = {{ $headers.STSIncludeSubdomains }}
|
STSIncludeSubdomains = {{ $headers.STSIncludeSubdomains }}
|
||||||
STSPreload = {{ $headers.STSPreload }}
|
STSPreload = {{ $headers.STSPreload }}
|
||||||
|
|
|
@ -128,6 +128,7 @@
|
||||||
SSLRedirect = {{ $headers.SSLRedirect }}
|
SSLRedirect = {{ $headers.SSLRedirect }}
|
||||||
SSLTemporaryRedirect = {{ $headers.SSLTemporaryRedirect }}
|
SSLTemporaryRedirect = {{ $headers.SSLTemporaryRedirect }}
|
||||||
SSLHost = "{{ $headers.SSLHost }}"
|
SSLHost = "{{ $headers.SSLHost }}"
|
||||||
|
SSLForceHost = {{ $headers.SSLForceHost }}
|
||||||
STSSeconds = {{ $headers.STSSeconds }}
|
STSSeconds = {{ $headers.STSSeconds }}
|
||||||
STSIncludeSubdomains = {{ $headers.STSIncludeSubdomains }}
|
STSIncludeSubdomains = {{ $headers.STSIncludeSubdomains }}
|
||||||
STSPreload = {{ $headers.STSPreload }}
|
STSPreload = {{ $headers.STSPreload }}
|
||||||
|
|
|
@ -127,6 +127,7 @@
|
||||||
SSLRedirect = {{ $headers.SSLRedirect }}
|
SSLRedirect = {{ $headers.SSLRedirect }}
|
||||||
SSLTemporaryRedirect = {{ $headers.SSLTemporaryRedirect }}
|
SSLTemporaryRedirect = {{ $headers.SSLTemporaryRedirect }}
|
||||||
SSLHost = "{{ $headers.SSLHost }}"
|
SSLHost = "{{ $headers.SSLHost }}"
|
||||||
|
SSLForceHost = {{ $headers.SSLForceHost }}
|
||||||
STSSeconds = {{ $headers.STSSeconds }}
|
STSSeconds = {{ $headers.STSSeconds }}
|
||||||
STSIncludeSubdomains = {{ $headers.STSIncludeSubdomains }}
|
STSIncludeSubdomains = {{ $headers.STSIncludeSubdomains }}
|
||||||
STSPreload = {{ $headers.STSPreload }}
|
STSPreload = {{ $headers.STSPreload }}
|
||||||
|
|
|
@ -100,6 +100,7 @@
|
||||||
SSLRedirect = {{ $frontend.Headers.SSLRedirect }}
|
SSLRedirect = {{ $frontend.Headers.SSLRedirect }}
|
||||||
SSLTemporaryRedirect = {{ $frontend.Headers.SSLTemporaryRedirect }}
|
SSLTemporaryRedirect = {{ $frontend.Headers.SSLTemporaryRedirect }}
|
||||||
SSLHost = "{{ $frontend.Headers.SSLHost }}"
|
SSLHost = "{{ $frontend.Headers.SSLHost }}"
|
||||||
|
SSLForceHost = {{ $frontend.Headers.SSLForceHost }}
|
||||||
STSSeconds = {{ $frontend.Headers.STSSeconds }}
|
STSSeconds = {{ $frontend.Headers.STSSeconds }}
|
||||||
STSIncludeSubdomains = {{ $frontend.Headers.STSIncludeSubdomains }}
|
STSIncludeSubdomains = {{ $frontend.Headers.STSIncludeSubdomains }}
|
||||||
STSPreload = {{ $frontend.Headers.STSPreload }}
|
STSPreload = {{ $frontend.Headers.STSPreload }}
|
||||||
|
|
|
@ -127,6 +127,7 @@
|
||||||
SSLRedirect = {{ $headers.SSLRedirect }}
|
SSLRedirect = {{ $headers.SSLRedirect }}
|
||||||
SSLTemporaryRedirect = {{ $headers.SSLTemporaryRedirect }}
|
SSLTemporaryRedirect = {{ $headers.SSLTemporaryRedirect }}
|
||||||
SSLHost = "{{ $headers.SSLHost }}"
|
SSLHost = "{{ $headers.SSLHost }}"
|
||||||
|
SSLForceHost = {{ $headers.SSLForceHost }}
|
||||||
STSSeconds = {{ $headers.STSSeconds }}
|
STSSeconds = {{ $headers.STSSeconds }}
|
||||||
STSIncludeSubdomains = {{ $headers.STSIncludeSubdomains }}
|
STSIncludeSubdomains = {{ $headers.STSIncludeSubdomains }}
|
||||||
STSPreload = {{ $headers.STSPreload }}
|
STSPreload = {{ $headers.STSPreload }}
|
||||||
|
|
|
@ -130,6 +130,7 @@
|
||||||
SSLRedirect = {{ $headers.SSLRedirect }}
|
SSLRedirect = {{ $headers.SSLRedirect }}
|
||||||
SSLTemporaryRedirect = {{ $headers.SSLTemporaryRedirect }}
|
SSLTemporaryRedirect = {{ $headers.SSLTemporaryRedirect }}
|
||||||
SSLHost = "{{ $headers.SSLHost }}"
|
SSLHost = "{{ $headers.SSLHost }}"
|
||||||
|
SSLForceHost = {{ $headers.SSLForceHost }}
|
||||||
STSSeconds = {{ $headers.STSSeconds }}
|
STSSeconds = {{ $headers.STSSeconds }}
|
||||||
STSIncludeSubdomains = {{ $headers.STSIncludeSubdomains }}
|
STSIncludeSubdomains = {{ $headers.STSIncludeSubdomains }}
|
||||||
STSPreload = {{ $headers.STSPreload }}
|
STSPreload = {{ $headers.STSPreload }}
|
||||||
|
|
|
@ -130,6 +130,7 @@
|
||||||
SSLRedirect = {{ $headers.SSLRedirect }}
|
SSLRedirect = {{ $headers.SSLRedirect }}
|
||||||
SSLTemporaryRedirect = {{ $headers.SSLTemporaryRedirect }}
|
SSLTemporaryRedirect = {{ $headers.SSLTemporaryRedirect }}
|
||||||
SSLHost = "{{ $headers.SSLHost }}"
|
SSLHost = "{{ $headers.SSLHost }}"
|
||||||
|
SSLForceHost = {{ $headers.SSLForceHost }}
|
||||||
STSSeconds = {{ $headers.STSSeconds }}
|
STSSeconds = {{ $headers.STSSeconds }}
|
||||||
STSIncludeSubdomains = {{ $headers.STSIncludeSubdomains }}
|
STSIncludeSubdomains = {{ $headers.STSIncludeSubdomains }}
|
||||||
STSPreload = {{ $headers.STSPreload }}
|
STSPreload = {{ $headers.STSPreload }}
|
||||||
|
|
|
@ -128,6 +128,7 @@
|
||||||
SSLRedirect = {{ $headers.SSLRedirect }}
|
SSLRedirect = {{ $headers.SSLRedirect }}
|
||||||
SSLTemporaryRedirect = {{ $headers.SSLTemporaryRedirect }}
|
SSLTemporaryRedirect = {{ $headers.SSLTemporaryRedirect }}
|
||||||
SSLHost = "{{ $headers.SSLHost }}"
|
SSLHost = "{{ $headers.SSLHost }}"
|
||||||
|
SSLForceHost = {{ $headers.SSLForceHost }}
|
||||||
STSSeconds = {{ $headers.STSSeconds }}
|
STSSeconds = {{ $headers.STSSeconds }}
|
||||||
STSIncludeSubdomains = {{ $headers.STSIncludeSubdomains }}
|
STSIncludeSubdomains = {{ $headers.STSIncludeSubdomains }}
|
||||||
STSPreload = {{ $headers.STSPreload }}
|
STSPreload = {{ $headers.STSPreload }}
|
||||||
|
|
|
@ -119,14 +119,16 @@ type RateLimit struct {
|
||||||
|
|
||||||
// Headers holds the custom header configuration
|
// Headers holds the custom header configuration
|
||||||
type Headers struct {
|
type Headers struct {
|
||||||
CustomRequestHeaders map[string]string `json:"customRequestHeaders,omitempty"`
|
CustomRequestHeaders map[string]string `json:"customRequestHeaders,omitempty"`
|
||||||
CustomResponseHeaders map[string]string `json:"customResponseHeaders,omitempty"`
|
CustomResponseHeaders map[string]string `json:"customResponseHeaders,omitempty"`
|
||||||
|
|
||||||
AllowedHosts []string `json:"allowedHosts,omitempty"`
|
AllowedHosts []string `json:"allowedHosts,omitempty"`
|
||||||
HostsProxyHeaders []string `json:"hostsProxyHeaders,omitempty"`
|
HostsProxyHeaders []string `json:"hostsProxyHeaders,omitempty"`
|
||||||
SSLRedirect bool `json:"sslRedirect,omitempty"`
|
SSLRedirect bool `json:"sslRedirect,omitempty"`
|
||||||
SSLTemporaryRedirect bool `json:"sslTemporaryRedirect,omitempty"`
|
SSLTemporaryRedirect bool `json:"sslTemporaryRedirect,omitempty"`
|
||||||
SSLHost string `json:"sslHost,omitempty"`
|
SSLHost string `json:"sslHost,omitempty"`
|
||||||
SSLProxyHeaders map[string]string `json:"sslProxyHeaders,omitempty"`
|
SSLProxyHeaders map[string]string `json:"sslProxyHeaders,omitempty"`
|
||||||
|
SSLForceHost bool `json:"sslForceHost,omitempty"`
|
||||||
STSSeconds int64 `json:"stsSeconds,omitempty"`
|
STSSeconds int64 `json:"stsSeconds,omitempty"`
|
||||||
STSIncludeSubdomains bool `json:"stsIncludeSubdomains,omitempty"`
|
STSIncludeSubdomains bool `json:"stsIncludeSubdomains,omitempty"`
|
||||||
STSPreload bool `json:"stsPreload,omitempty"`
|
STSPreload bool `json:"stsPreload,omitempty"`
|
||||||
|
@ -154,6 +156,7 @@ func (h *Headers) HasSecureHeadersDefined() bool {
|
||||||
len(h.HostsProxyHeaders) != 0 ||
|
len(h.HostsProxyHeaders) != 0 ||
|
||||||
h.SSLRedirect ||
|
h.SSLRedirect ||
|
||||||
h.SSLTemporaryRedirect ||
|
h.SSLTemporaryRedirect ||
|
||||||
|
h.SSLForceHost ||
|
||||||
h.SSLHost != "" ||
|
h.SSLHost != "" ||
|
||||||
len(h.SSLProxyHeaders) != 0 ||
|
len(h.SSLProxyHeaders) != 0 ||
|
||||||
h.STSSeconds != 0 ||
|
h.STSSeconds != 0 ||
|
||||||
|
|
98
vendor/github.com/unrolled/secure/secure.go
generated
vendored
98
vendor/github.com/unrolled/secure/secure.go
generated
vendored
|
@ -27,7 +27,7 @@ const (
|
||||||
cspNonceSize = 16
|
cspNonceSize = 16
|
||||||
)
|
)
|
||||||
|
|
||||||
// a type whose pointer is the type of field `SSLHostFunc` of `Options` struct
|
// SSLHostFunc a type whose pointer is the type of field `SSLHostFunc` of `Options` struct
|
||||||
type SSLHostFunc func(host string) (newHost string)
|
type SSLHostFunc func(host string) (newHost string)
|
||||||
|
|
||||||
func defaultBadHostHandler(w http.ResponseWriter, r *http.Request) {
|
func defaultBadHostHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
@ -36,16 +36,47 @@ func defaultBadHostHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
// Options is a struct for specifying configuration options for the secure.Secure middleware.
|
// Options is a struct for specifying configuration options for the secure.Secure middleware.
|
||||||
type Options struct {
|
type Options struct {
|
||||||
|
// If BrowserXssFilter is true, adds the X-XSS-Protection header with the value `1; mode=block`. Default is false.
|
||||||
|
BrowserXssFilter bool // nolint: golint
|
||||||
|
// If ContentTypeNosniff is true, adds the X-Content-Type-Options header with the value `nosniff`. Default is false.
|
||||||
|
ContentTypeNosniff bool
|
||||||
|
// If ForceSTSHeader is set to true, the STS header will be added even when the connection is HTTP. Default is false.
|
||||||
|
ForceSTSHeader bool
|
||||||
|
// If FrameDeny is set to true, adds the X-Frame-Options header with the value of `DENY`. Default is false.
|
||||||
|
FrameDeny bool
|
||||||
|
// When developing, the AllowedHosts, SSL, and STS options can cause some unwanted effects. Usually testing happens on http, not https, and on localhost, not your production domain... so set this to true for dev environment.
|
||||||
|
// If you would like your development environment to mimic production with complete Host blocking, SSL redirects, and STS headers, leave this as false. Default if false.
|
||||||
|
IsDevelopment bool
|
||||||
|
// nonceEnabled is used internally for dynamic nouces.
|
||||||
|
nonceEnabled bool
|
||||||
|
// If SSLRedirect is set to true, then only allow https requests. Default is false.
|
||||||
|
SSLRedirect bool
|
||||||
|
// If SSLForceHost is true and SSLHost is set, requests will be forced to use SSLHost even the ones that are already using SSL. Default is false.
|
||||||
|
SSLForceHost bool
|
||||||
|
// If SSLTemporaryRedirect is true, the a 302 will be used while redirecting. Default is false (301).
|
||||||
|
SSLTemporaryRedirect bool
|
||||||
|
// If STSIncludeSubdomains is set to true, the `includeSubdomains` will be appended to the Strict-Transport-Security header. Default is false.
|
||||||
|
STSIncludeSubdomains bool
|
||||||
|
// If STSPreload is set to true, the `preload` flag will be appended to the Strict-Transport-Security header. Default is false.
|
||||||
|
STSPreload bool
|
||||||
|
// ContentSecurityPolicy allows the Content-Security-Policy header value to be set with a custom value. Default is "".
|
||||||
|
ContentSecurityPolicy string
|
||||||
|
// CustomBrowserXssValue allows the X-XSS-Protection header value to be set with a custom value. This overrides the BrowserXssFilter option. Default is "".
|
||||||
|
CustomBrowserXssValue string // nolint: golint
|
||||||
|
// Passing a template string will replace `$NONCE` with a dynamic nonce value of 16 bytes for each request which can be later retrieved using the Nonce function.
|
||||||
|
// Eg: script-src $NONCE -> script-src 'nonce-a2ZobGFoZg=='
|
||||||
|
// CustomFrameOptionsValue allows the X-Frame-Options header value to be set with a custom value. This overrides the FrameDeny option. Default is "".
|
||||||
|
CustomFrameOptionsValue string
|
||||||
|
// PublicKey implements HPKP to prevent MITM attacks with forged certificates. Default is "".
|
||||||
|
PublicKey string
|
||||||
|
// ReferrerPolicy allows sites to control when browsers will pass the Referer header to other sites. Default is "".
|
||||||
|
ReferrerPolicy string
|
||||||
|
// SSLHost is the host name that is used to redirect http requests to https. Default is "", which indicates to use the same host.
|
||||||
|
SSLHost string
|
||||||
// AllowedHosts is a list of fully qualified domain names that are allowed. Default is empty list, which allows any and all host names.
|
// AllowedHosts is a list of fully qualified domain names that are allowed. Default is empty list, which allows any and all host names.
|
||||||
AllowedHosts []string
|
AllowedHosts []string
|
||||||
// HostsProxyHeaders is a set of header keys that may hold a proxied hostname value for the request.
|
// HostsProxyHeaders is a set of header keys that may hold a proxied hostname value for the request.
|
||||||
HostsProxyHeaders []string
|
HostsProxyHeaders []string
|
||||||
// If SSLRedirect is set to true, then only allow https requests. Default is false.
|
|
||||||
SSLRedirect bool
|
|
||||||
// If SSLTemporaryRedirect is true, the a 302 will be used while redirecting. Default is false (301).
|
|
||||||
SSLTemporaryRedirect bool
|
|
||||||
// SSLHost is the host name that is used to redirect http requests to https. Default is "", which indicates to use the same host.
|
|
||||||
SSLHost string
|
|
||||||
// SSLHostFunc is a function pointer, the return value of the function is the host name that has same functionality as `SSHost`. Default is nil.
|
// SSLHostFunc is a function pointer, the return value of the function is the host name that has same functionality as `SSHost`. Default is nil.
|
||||||
// If SSLHostFunc is nil, the `SSLHost` option will be used.
|
// If SSLHostFunc is nil, the `SSLHost` option will be used.
|
||||||
SSLHostFunc *SSLHostFunc
|
SSLHostFunc *SSLHostFunc
|
||||||
|
@ -53,35 +84,6 @@ type Options struct {
|
||||||
SSLProxyHeaders map[string]string
|
SSLProxyHeaders map[string]string
|
||||||
// STSSeconds is the max-age of the Strict-Transport-Security header. Default is 0, which would NOT include the header.
|
// STSSeconds is the max-age of the Strict-Transport-Security header. Default is 0, which would NOT include the header.
|
||||||
STSSeconds int64
|
STSSeconds int64
|
||||||
// If STSIncludeSubdomains is set to true, the `includeSubdomains` will be appended to the Strict-Transport-Security header. Default is false.
|
|
||||||
STSIncludeSubdomains bool
|
|
||||||
// If STSPreload is set to true, the `preload` flag will be appended to the Strict-Transport-Security header. Default is false.
|
|
||||||
STSPreload bool
|
|
||||||
// If ForceSTSHeader is set to true, the STS header will be added even when the connection is HTTP. Default is false.
|
|
||||||
ForceSTSHeader bool
|
|
||||||
// If FrameDeny is set to true, adds the X-Frame-Options header with the value of `DENY`. Default is false.
|
|
||||||
FrameDeny bool
|
|
||||||
// CustomFrameOptionsValue allows the X-Frame-Options header value to be set with a custom value. This overrides the FrameDeny option. Default is "".
|
|
||||||
CustomFrameOptionsValue string
|
|
||||||
// If ContentTypeNosniff is true, adds the X-Content-Type-Options header with the value `nosniff`. Default is false.
|
|
||||||
ContentTypeNosniff bool
|
|
||||||
// If BrowserXssFilter is true, adds the X-XSS-Protection header with the value `1; mode=block`. Default is false.
|
|
||||||
BrowserXssFilter bool
|
|
||||||
// CustomBrowserXssValue allows the X-XSS-Protection header value to be set with a custom value. This overrides the BrowserXssFilter option. Default is "".
|
|
||||||
CustomBrowserXssValue string
|
|
||||||
// ContentSecurityPolicy allows the Content-Security-Policy header value to be set with a custom value. Default is "".
|
|
||||||
// Passing a template string will replace `$NONCE` with a dynamic nonce value of 16 bytes for each request which can be later retrieved using the Nonce function.
|
|
||||||
// Eg: script-src $NONCE -> script-src 'nonce-a2ZobGFoZg=='
|
|
||||||
ContentSecurityPolicy string
|
|
||||||
// PublicKey implements HPKP to prevent MITM attacks with forged certificates. Default is "".
|
|
||||||
PublicKey string
|
|
||||||
// ReferrerPolicy allows sites to control when browsers will pass the Referer header to other sites. Default is "".
|
|
||||||
ReferrerPolicy string
|
|
||||||
// When developing, the AllowedHosts, SSL, and STS options can cause some unwanted effects. Usually testing happens on http, not https, and on localhost, not your production domain... so set this to true for dev environment.
|
|
||||||
// If you would like your development environment to mimic production with complete Host blocking, SSL redirects, and STS headers, leave this as false. Default if false.
|
|
||||||
IsDevelopment bool
|
|
||||||
// nonceEnabled is used internally for dynamic nouces.
|
|
||||||
nonceEnabled bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Secure is a middleware that helps setup a few basic security features. A single secure.Options struct can be
|
// Secure is a middleware that helps setup a few basic security features. A single secure.Options struct can be
|
||||||
|
@ -266,6 +268,30 @@ func (s *Secure) processRequest(w http.ResponseWriter, r *http.Request) (http.He
|
||||||
return nil, fmt.Errorf("redirecting to HTTPS")
|
return nil, fmt.Errorf("redirecting to HTTPS")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if s.opt.SSLForceHost {
|
||||||
|
var SSLHost = host;
|
||||||
|
if s.opt.SSLHostFunc != nil {
|
||||||
|
if h := (*s.opt.SSLHostFunc)(host); len(h) > 0 {
|
||||||
|
SSLHost = h
|
||||||
|
}
|
||||||
|
} else if len(s.opt.SSLHost) > 0 {
|
||||||
|
SSLHost = s.opt.SSLHost
|
||||||
|
}
|
||||||
|
if SSLHost != host {
|
||||||
|
url := r.URL
|
||||||
|
url.Scheme = "https"
|
||||||
|
url.Host = SSLHost
|
||||||
|
|
||||||
|
status := http.StatusMovedPermanently
|
||||||
|
if s.opt.SSLTemporaryRedirect {
|
||||||
|
status = http.StatusTemporaryRedirect
|
||||||
|
}
|
||||||
|
|
||||||
|
http.Redirect(w, r, url.String(), status)
|
||||||
|
return nil, fmt.Errorf("redirecting to HTTPS")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Create our header container.
|
// Create our header container.
|
||||||
responseHeader := make(http.Header)
|
responseHeader := make(http.Header)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue