
global
    maxconn 100000
    spread-checks 50
    #stats socket /tmp/haproxy mode 777


frontend frontend 0.0.0.0:80
    mode http
    maxconn 50000
    timeout client 10000
    option forwardfor except 127.0.0.1
    option httpclose

    option httplog
    log /dev/log local4
    capture request header User-Agent len 150
    capture request header Host len 50
    capture request header Referer len 300
    capture request header X-Forwarded-For len 15
    capture request header True-Client-Ip len 15
    capture request header If-Modified-Since len 50
    capture cookie reddit_session= len 25

    # make comescore a static thing
    reqrep ^(.*)/comscore-iframe/(.*) \1/static/comscore.html?path=\2


    # make the iphone url pretty
    reqirep ^GET\ /iphone/(.*) GET\ /static/iphone/\1

    # make the socialite url pretty
    reqirep ^GET\ /socialite/(.*) GET\ /static/socialite/\1

    # make the redditaddict url pretty
    reqirep ^GET\ /redditaddict/(.*) GET\ /static/redditaddict/\1

    ########
    # button rewrites
    reqirep ^GET\ /button\.js\ (.*) GET\ /static/button/button1.js\ \1
    reqirep ^GET\ /button\.js\?t=([0-9])\ (.*) GET\ /static/button/button\1.js\ \2
    reqirep ^GET\ /r/(.*)/button\.js\?t=([0-9])\ (.*) GET\ /static/button/button\2.js\ \3
    reqirep ^GET\ /button\.js\?t=([0-9])&width=[0-9]+&height=[0-9]+\ (.*) GET\ /static/button/button\1.js\ \2

    ### acls

    #ssl only to pay urls
    acl sslrequest src 127.0.0.1
    acl sslallowed path_beg /promoted
    acl sslallowed path_beg /static 
    acl sslallowed path_beg /api
    
    default_backend dynamic

backend dynamic
    mode http
    timeout connect 4000
    timeout server 30000
    timeout queue 60000
    balance roundrobin
    capture cookie reddit_session= len 25 
    option httpchk GET /health HTTP/1.1\r\nHost:\ reddit.local

    server app01-8001 localhost:8001 maxconn 1 check fall 1
    server app01-8002 localhost:8002 maxconn 1 check fall 1

listen stats 0.0.0.0:9000
    mode http
    balance
    timeout client 5000
    timeout connect 4000
    timeout server 30000
    stats uri /haproxy_stats

