Azure Service Fabric Provider

Traefik can be configured to use Azure Service Fabric as a provider.

See this repository for an example deployment package and further documentation.

Azure Service Fabric

  1. ################################################################
  2. # Azure Service Fabric Provider
  3. ################################################################
  4. # Enable Azure Service Fabric Provider
  5. [serviceFabric]
  6. # Azure Service Fabric Management Endpoint
  7. #
  8. # Required
  9. #
  10. clusterManagementUrl = "https://localhost:19080"
  11. # Azure Service Fabric Management Endpoint API Version
  12. #
  13. # Required
  14. # Default: "3.0"
  15. #
  16. apiVersion = "3.0"
  17. # Azure Service Fabric Polling Interval (in seconds)
  18. #
  19. # Required
  20. # Default: 10
  21. #
  22. refreshSeconds = 10
  23. # Enable TLS connection.
  24. #
  25. # Optional
  26. #
  27. # [serviceFabric.tls]
  28. # ca = "/etc/ssl/ca.crt"
  29. # cert = "/etc/ssl/servicefabric.crt"
  30. # key = "/etc/ssl/servicefabric.key"
  31. # insecureSkipVerify = true

Labels

The provider uses labels to configure how services are exposed through Traefik. These can be set using Extensions and the Property Manager API

Extensions

Set labels with extensions through the services ServiceManifest.xml file. Here is an example of an extension setting Traefik labels:

  1. <StatelessServiceType ServiceTypeName="WebServiceType">
  2. <Extensions>
  3. <Extension Name="Traefik">
  4. <Labels xmlns="http://schemas.microsoft.com/2015/03/fabact-no-schema">
  5. <Label Key="traefik.frontend.rule.example2">PathPrefixStrip: /a/path/to/strip</Label>
  6. <Label Key="traefik.enable">true</Label>
  7. <Label Key="traefik.frontend.passHostHeader">true</Label>
  8. </Labels>
  9. </Extension>
  10. </Extensions>
  11. </StatelessServiceType>

Note: The Label tag and its Key attribute are case sensitive. That is, if you use label instead of Label or key instead of Key, they will be silently ignored.

Property Manager

Set Labels with the property manager API to overwrite and add labels, while your service is running. Here is an example of adding a frontend rule using the property manager API.

  1. curl -X PUT \
  2. 'http://localhost:19080/Names/GettingStartedApplication2/WebService/$/GetProperty?api-version=6.0&IncludeValues=true' \
  3. -d '{
  4. "PropertyName": "traefik.frontend.rule.default",
  5. "Value": {
  6. "Kind": "String",
  7. "Data": "PathPrefixStrip: /a/path/to/strip"
  8. },
  9. "CustomTypeId": "LabelType"
  10. }'

Note

This functionality will be released in a future version of the sfctl tool.

Available Labels

Labels, set through extensions or the property manager, can be used on services to override default behavior.

Label Description
traefik.enable=false Disable this container in Traefik
traefik.backend.circuitbreaker.expression=EXPR Create a circuit breaker to be used against the backend
traefik.servicefabric.groupname Group all services with the same name into a single backend in Traefik
traefik.servicefabric.groupweight Set the weighting of the current services nodes in the backend group
traefik.servicefabric.enablelabeloverrides Toggle whether labels can be overridden using the Service Fabric Property Manager API
traefik.servicefabric.endpointname Specify the name of the endpoint
traefik.backend.healthcheck.path=/health Enable health check for the backend, hitting the container at path.
traefik.backend.healthcheck.port=8080 Allow to use a different port for the health check.
traefik.backend.healthcheck.interval=1s Define the health check interval.
traefik.backend.healthcheck.hostname=foobar.com Define the health check hostname.
traefik.backend.healthcheck.headers=EXPR Define the health check request headers Format: HEADER:value||HEADER2:value2
traefik.backend.loadbalancer.method=drr Override the default wrr load balancer algorithm
traefik.backend.loadbalancer.stickiness=true Enable backend sticky sessions
traefik.backend.loadbalancer.stickiness.cookieName=NAME Manually set the cookie name for sticky sessions
traefik.backend.loadbalancer.sticky=true Enable backend sticky sessions (DEPRECATED)
traefik.backend.maxconn.amount=10 Set a maximum number of connections to the backend. Must be used in conjunction with the below label to take effect.
traefik.backend.maxconn.extractorfunc=client.ip Set the function to be used against the request to determine what to limit maximum connections to the backend by. Must be used in conjunction with the above label to take effect.
traefik.backend.weight=10 Assign this weight to the container
traefik.frontend.auth.basic=EXPR Sets basic authentication for that frontend in CSV format: User:Hash,User:Hash
traefik.frontend.entryPoints=http,https Assign this frontend to entry points http and https. Overrides defaultEntryPoints
traefik.frontend.passHostHeader=true Forward client Host header to the backend.
traefik.frontend.passTLSCert=true Forward TLS Client certificates to the backend.
traefik.frontend.priority=10 Override default frontend priority
traefik.frontend.redirect.entryPoint=https Enables Redirect to another entryPoint for that frontend (e.g. HTTPS)
traefik.frontend.redirect.regex=^http://localhost/(.\*) Redirect to another URL for that frontend. Must be set with traefik.frontend.redirect.replacement.
traefik.frontend.redirect.replacement=http://mydomain/$1 Redirect to another URL for that frontend. Must be set with traefik.frontend.redirect.regex.
traefik.frontend.redirect.permanent=true Return 301 instead of 302.
traefik.frontend.rule=EXPR Override the default frontend rule. Defaults to SF address.
traefik.frontend.whiteList.sourceRange=RANGE List of IP-Ranges which are allowed to access. An unset or empty list allows all Source-IPs to access. If one of the Net-Specifications are invalid, the whole list is invalid and allows all Source-IPs to access.
traefik.frontend.whiteList.useXForwardedFor=true Use X-Forwarded-For header as valid source of IP for the white list.

Custom Headers

Label Description
traefik.frontend.headers.customRequestHeaders=EXPR Provides the container with custom request headers that will be appended to each request forwarded to the container. Format: HEADER:value||HEADER2:value2
traefik.frontend.headers.customResponseHeaders=EXPR Appends the headers to each response returned by the container, before forwarding the response to the client. Format: HEADER:value||HEADER2:value2

Security Headers

Label Description
traefik.frontend.headers.allowedHosts=EXPR Provides a list of allowed hosts that requests will be processed. Format: Host1,Host2
traefik.frontend.headers.hostsProxyHeaders=EXPR Provides a list of headers that the proxied hostname may be stored. Format: HEADER1,HEADER2
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.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.SSLProxyHeaders=EXPR Header combinations that would signify a proper SSL Request (Such as X-Forwarded-Proto:https). Format: HEADER:value||HEADER2:value2
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.STSPreload=true Adds the preload flag to the STS header.
traefik.frontend.headers.forceSTSHeader=false Adds the STS header to non-SSL requests.
traefik.frontend.headers.frameDeny=false Adds the X-Frame-Options header with the value of DENY.
traefik.frontend.headers.customFrameOptionsValue=VALUE Overrides the X-Frame-Options header with the custom value.
traefik.frontend.headers.contentTypeNosniff=true Adds the X-Content-Type-Options header with the value nosniff.
traefik.frontend.headers.browserXSSFilter=true Adds the X-XSS-Protection header with the value 1; mode=block.
traefik.frontend.headers.customBrowserXSSValue=VALUE Set custom value for X-XSS-Protection header. This overrides the BrowserXssFilter option.
traefik.frontend.headers.contentSecurityPolicy=VALUE Adds CSP Header with the custom value.
traefik.frontend.headers.publicKey=VALUE Adds HPKP header.
traefik.frontend.headers.referrerPolicy=VALUE Adds referrer policy header.
traefik.frontend.headers.isDevelopment=false This will cause the AllowedHosts, SSLRedirect, and STSSeconds/STSIncludeSubdomains options to be ignored during development. When deploying to production, be sure to set this to false.