Skip to content

Instantly share code, notes, and snippets.

@hongry18
Last active April 4, 2018 02:30
Show Gist options
  • Save hongry18/b49a8362a1ed1052369647be7d925096 to your computer and use it in GitHub Desktop.
Save hongry18/b49a8362a1ed1052369647be7d925096 to your computer and use it in GitHub Desktop.
haproxy setting was, websocket

haproxy.cfg

global
    tune.ssl.default-dh-param 2048
    log               127.0.0.1 local0 notice
    user              root
    group             root

defaults
    mode              http
    option            dontlognull
    option            redispatch
    option            forwardfor
    option            http-server-close
    retries           3
    maxconn           40960

    # timeout settings
    timeout           check           10s
    timeout           client          25s
    timeout           connect          5s
    timeout           server          25s
    timeout           http-keep-alive  3s
    timeout           http-request    15s
    timeout           queue           30s
    timeout           tarpit          60s

    # log
    log               global
    option            httplog

# 80 port setting, redirect to 443 port
frontend              http_front
    bind              *:80
    redirect          scheme https code 301 if !{ ssl_fc }

# 443 port setting
frontend              https_front
    bind              *:443 ssl crt ssl.pem
    default_backend   bk_was

    # websocket setting
    acl is_websocket path_beg /mainWebsocket
    acl is_websocket hdr(Upgrade) -i WebSocket
    acl is_websocket hdr_beg(Host) -i ws

    # was lists
    backend               bk_was
        mode              http
        option            httpclose
        option            forwardfor
        reqadd            X-Forwarded-Proto:\ https

        # server list
        balance           leastconn
        server            server-1 dest:port check
        server            server-2 dest:port check

    # webserver lists
    backend               bk_ws
        option http-server-close
        option forceclose

        # server list
        server            server-1 dest:port check
        server            server-2 dest:port check
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment