Skip to content

Instantly share code, notes, and snippets.

@danihodovic
Created June 25, 2018 17:36
Show Gist options
  • Save danihodovic/c89d685b95b1023fc16591b6e74d1134 to your computer and use it in GitHub Desktop.
Save danihodovic/c89d685b95b1023fc16591b6e74d1134 to your computer and use it in GitHub Desktop.
Testing HAProxy backend DNS resolution
const http = require('http');
const os = require('os');
let num = 0;
setTimeout(() => {
console.log(os.hostname(), num);
process.exit(0);
}, 60000);
http.createServer(function (req, res) {
num++;
res.write('OK');
res.end();
}).listen(8000);
---
version: '2'
services:
haproxy:
image: haproxy
ports:
- '80:80'
volumes:
- './haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg'
api:
image: node
command: node /app.js
volumes:
- './app.js:/app.js'
resolvers docker
nameserver default 127.0.0.11:53
hold valid 1000ms
frontend proxy
mode http
bind 0.0.0.0:80 maxconn 10000
option http-server-close
option forwardfor
timeout client 5000
default_backend api
backend api
mode http
timeout connect 100
timeout server 5000
option httpchk GET /
server-template api 5 api:8000 maxconn 10000 check inter 1000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment