Skip to content

Instantly share code, notes, and snippets.

@tonythere
Last active January 6, 2016 14:03
Show Gist options
  • Select an option

  • Save tonythere/0e4fc0a80a18dac6072c to your computer and use it in GitHub Desktop.

Select an option

Save tonythere/0e4fc0a80a18dac6072c to your computer and use it in GitHub Desktop.
global
log 127.0.0.1 local1 notice
maxconn 4096
user haproxy
group haproxy
daemon
defaults
log global
maxconn 4096
mode http
# Add x-forwarded-for header.
option forwardfor
option http-server-close
timeout connect 5s
timeout client 30s
timeout server 30s
# Long timeout for WebSocket connections.
timeout tunnel 1h
frontend public
# HTTP
bind :80
# Redirect all HTTP traffic to HTTPS
redirect scheme https if !{ ssl_fc }
# HTTPS
# Example with CA certificate bundle
# bind :443 ssl crt cert.pem ca-file bundle.crt
# Example without CA certification bunch
bind :443 ssl crt /etc/letsencrypt/live/mientay.xyz/fullchain.pem
default_backend bk_default
backend bk_default
# Tell the backend that this is a secure connection,
# even though it's getting plain HTTP.
reqadd X-Forwarded-Proto: https
balance leastconn
# Check by hitting a page intended for this use.
# option httpchk GET /isrunning
# timeout check 500ms
# Wait 500ms between checks.
server node1 127.0.0.1:8081 check inter 500ms
# For displaying HAProxy statistics.
frontend stats
bind :1936 ssl crt /etc/letsencrypt/live/mientay.xyz/fullchain.pem
default_backend stats
backend stats
stats enable
stats hide-version
stats realm Haproxy Statistics
stats uri /
stats auth admin:123457
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment