global maxconn 100000 daemon ca-base /srv/newsblur/config/certificates crt-base /srv/newsblur/config/certificates tune.bufsize 32000 tune.maxrewrite 8196 tune.ssl.default-dh-param 2048 # HTTP/2 performance tuning for high-latency connections tune.h2.initial-window-size 1048576 tune.h2.max-concurrent-streams 250 log 127.0.0.1 local0 notice # log 127.0.0.1 local1 info # Use Docker's embedded DNS so backend hostnames can be re-resolved at runtime. # Combined with `init-addr last,libc,none` on each server line, this lets haproxy # boot even when a backend container is down or restarting — otherwise haproxy # fails to start if any backend hostname can't be resolved at load time, which # takes the whole site offline for an unrelated container crash. resolvers docker nameserver dns1 127.0.0.11:53 resolve_retries 3 timeout resolve 1s timeout retry 1s hold valid 5s defaults log global maxconn 100000 mode http option forwardfor option http-server-close # option httpclose # Disabled: breaks HTTP/2 multiplexing causing ERR_HTTP2_PROTOCOL_ERROR option log-health-checks option log-separate-errors option httplog option redispatch option abortonclose timeout connect 10s timeout client 10s timeout server 30s timeout tunnel 1h retries 3 errorfile 502 /srv/newsblur/templates/502.http errorfile 503 /srv/newsblur/templates/502.http errorfile 504 /srv/newsblur/templates/502.http frontend public bind :80 bind :443 ssl crt /srv/newsblur/config/certificates/localhost.pem #ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES128-SHA:AES256-SHA256:AES256-SHA no-sslv3 http-response add-header Strict-Transport-Security max-age=31536000;\ includeSubDomains http-request set-header X-Request-Start %[date()]%[date_us()] option http-server-close # Hosts listed in docker/haproxy/local.d/hosts.map stay on HTTP and go to the backend the map # names. local.d holds machine-only backends and has none in a fresh checkout. acl is_local_host req.hdr(host),host_only,lower,map(opt@/srv/newsblur/docker/haproxy/local.d/hosts.map) -m found redirect scheme https if !{ ssl_fc } !is_local_host # Block vulnerability scanners before they reach Gunicorn workers acl is_scanner_path path_end .php .cgi .asp .aspx .env acl is_scanner_path path_beg /wp-admin /wp-login /wp-content /wp-includes http-request deny deny_status 403 if is_scanner_path acl gunicorn_dead nbsrv(gunicorn) lt 1 acl nginx_dead nbsrv(nginx) lt 1 acl is_unread_count url_beg /reader/feed_unread_count acl is_discover url_beg /discover/feed acl is_refresh_feeds url_beg /reader/refresh_feed monitor-uri /status monitor fail if gunicorn_dead monitor fail if nginx_dead use_backend node_socket if { path_beg /v3/socket.io/ } use_backend node_favicon if { path_beg /rss_feeds/icon/ } use_backend node_text if { path_beg /rss_feeds/original_text_fetcher } use_backend node_text if { path_beg /listen/stream/ } use_backend node_page if { path_beg /original_page/ } use_backend node_images if { path_beg /imageproxy/ } use_backend nginx if { path_beg /media/ } use_backend nginx if { path_beg /static/ } use_backend nginx if { path_beg /favicon } use_backend nginx if { path_beg /crossdomain/ } use_backend nginx if { path_beg /robots } use_backend nginx if { hdr_sub(host) -i blog.localhost } #use_backend self if { path_beg /munin/ } use_backend %[req.hdr(host),host_only,lower,map(opt@/srv/newsblur/docker/haproxy/local.d/hosts.map)] if is_local_host # use_backend gunicorn_counts if is_unread_count # use_backend gunicorn_refresh if is_refresh_feeds use_backend mcp if { path /mcp } || { path_beg /mcp/ } use_backend gunicorn unless gunicorn_dead || nginx_dead backend node_images option httpchk HEAD / http-check expect rstatus 200|301 http-request replace-path /imageproxy(.*) \1 server node_images newsblur_imageproxy:8088 check inter 600000ms resolvers docker init-addr last,libc,none backend node_socket http-check expect rstatus 200|503 balance roundrobin # Enable WebSocket support - disable connection closing options no option http-server-close no option httpclose timeout server 3600s server node_socket newsblur_node:8008 check inter 3000ms resolvers docker init-addr last,libc,none backend node_favicon http-check expect rstatus 200|301|503 # option httpchk GET /rss_feeds/icon/1 balance roundrobin server node_favicon newsblur_node:8008 check inter 3000ms resolvers docker init-addr last,libc,none backend node_text http-check expect rstatus 200|503 option httpchk GET /rss_feeds/original_text_fetcher?test=1 balance roundrobin server node_text newsblur_node:8008 check inter 3000ms resolvers docker init-addr last,libc,none backend node_page http-check expect rstatus 200|503 option httpchk GET /rss_feeds/original_text_fetcher?test=1 balance roundrobin server node_page newsblur_node:8008 check inter 3000ms resolvers docker init-addr last,libc,none backend nginx balance roundrobin option httpchk GET /_nginxchk http-check expect rstatus 200|503 server nginx newsblur_nginx:81 check inter 60000ms resolvers docker init-addr last,libc,none backend gunicorn balance roundrobin # option httpchk GET /_haproxychk server app_django nb.com:8000 check inter 3000ms resolvers docker init-addr last,libc,none backend postgres server db_postgres newsblur_db_postgres:5432 check inter 2000ms resolvers docker init-addr last,libc,none backend mongo server db_mongo newsblur_db_mongo:29019 check inter 2000ms resolvers docker init-addr last,libc,none backend redis server db_redis newsblur_db_redis:6579 check inter 2000ms resolvers docker init-addr last,libc,none server db_redis_pubsub newsblur_db_redis:6579 check inter 2000ms resolvers docker init-addr last,libc,none backend redis_story server db_redis_story newsblur_db_redis:6579 check inter 2000ms resolvers docker init-addr last,libc,none backend redis_sessions server db_redis_sessions newsblur_db_redis:6579 check inter 2000ms resolvers docker init-addr last,libc,none backend elasticsearch server db_elasticsearch newsblur_db_elasticsearch:9200 check inter 2000ms resolvers docker init-addr last,libc,none backend mcp timeout client 1h timeout server 1h timeout tunnel 1h http-request replace-path /mcp$ / http-request replace-path /mcp/(.*) /\1 server newsblur_mcp newsblur_mcp:8099 check inter 3000ms resolvers docker init-addr last,libc,none listen stats bind :1936 ssl crt /srv/newsblur/config/certificates/localhost.pem stats enable stats hide-version stats realm Haproxy\ Statistics stats uri / stats auth gimmiestats:StatsGiver stats refresh 15s