关联应用服务里的设置
Settings here can overwrite the settings in HAProxy, which are only applied to the linked services. If run in Docker Cloud, when the service redeploys, joins or leaves HAProxy service, HAProxy service will automatically update itself to apply the changes
Environment Variable | Description |
---|---|
APPSESSION | 粘性会话选项, 可能值 JSESSIONID len 52 timeout 3h . See:HAProxy:appsession |
BALANCE | load balancing algorithm to use. Possible values include: roundrobin , static-rr , source , leastconn . See:HAProxy:balance |
COOKIE | sticky session option. Possible value SRV insert indirect nocache . See:HAProxy:cookie |
DEFAULT_SSL_CERT | similar to SSL_CERT, but stores the pem file at /certs/cert0.pem as the default ssl certs. If multiple DEFAULT_SSL_CERT are specified in linked services and HAProxy, the behavior is undefined |
EXCLUDE_PORTS | comma separated port numbers(e.g. 3306, 3307). By default, HAProxy will add all the ports exposed by the application services to the backend routes. You can exclude the ports that you don't want to be routed, like database port |
EXTRA_ROUTE_SETTINGS | a string which is append to the each backend route after the health check,possible value: "send-proxy" |
EXTRA_SETTINGS | comma-separated string of extra settings, and each part will be appended to either related backend section or listen session in the configuration file. To escape comma, use \, . Possible value: balance source |
FORCE_SSL | if set(any value) together with ssl termination enabled. HAProxy will redirect HTTP request to HTTPS request. |
GZIP_COMPRESSION_TYPE | enable gzip compression. The value of this envvar is a list of MIME types that will be compressed. Some possible values: text/html text/plain text/css application/javascript . See:HAProxy:compression |
HEALTH_CHECK | set health check on each backend route, possible value: "check inter 2000 rise 2 fall 3". See:HAProxy:check |
HSTS_MAX_AGE | enable HSTS. It is an integer representing the max age of HSTS in seconds, possible value: 31536000 |
HTTP_CHECK | enable HTTP protocol to check on the servers health, possible value: "OPTIONS * HTTP/1.1\r\nHost:\ www". See:HAProxy:httpchk |
OPTION | comma-separated list of HAProxy option entries. option specified here will be added to related backend or listen part, and overwrite the OPTION settings in the HAProxy container |
SSL_CERT | ssl cert, a pem file with private key followed by public certificate, '\n'(two chars) as the line separator |
TCP_PORTS | comma separated ports(e.g. 9000, 9001, 2222/ssl). The port listed in TCP_PORTS will be load-balanced in TCP mode. Port ends with /ssl indicates that port needs SSL termination. |
VIRTUAL_HOST_WEIGHT | an integer of the weight of an virtual host, used together with VIRTUAL_HOST , default:0. It affects the order of acl rules of the virtual hosts. The higher weight one virtual host has, the more priority that acl rules applies. |
VIRTUAL_HOST | specify virtual host and virtual path. Format: [scheme://]domain[:port][/path], ... . wildcard * can be used in domain and path part |
Swarm Mode only settings:
名字 | 类型 | 描述 | |
---|---|---|---|
SERVICE_PORTS | envvar | comma separated ports(e.g. 80, 8080), which are the ports you would like to expose in your application service. This envvar is swarm mode only, and it is MUST be set in swarm mode | |
`com.docker.dockercloud.haproxy.deactivate=<true\ | false>` | label | when this label is set to true, haproxy will ignore the service. Could be useful for switching services on blue/green testing |
Check the HAProxy configuration manual for more information on the above.
example of stackfile in Docker Cloud with settings in linked application:
web:
image: 'dockercloud/hello-world:latest'
target_num_containers: 2
environment:
- TCP_PORTS=443
- EXCLUDE_PORTS=22
lb:
image: 'dockercloud/haproxy:latest'
links:
- web
ports:
- '80:80'
roles:
- global