Example
Serving application
Text Only
global
log stdout local0 info
log /dev/log local0 info alert
log /dev/log local1 notice alert
user root
# group nogroup
daemon
defaults
log global
option dontlognull
timeout connect 5000
timeout client 50000
timeout server 50000
listen mqtt_2883
bind *:2883
timeout connect 7000
timeout client 70000
timeout server 70000
timeout tunnel 3600s
mode tcp
option tcplog
log #{PRIV_IP} local0 debug
server mqtt_1883 mosquitto:1883 check
frontend http
mode http
bind *:80
# Certbot
acl letsencrypt_challenge path_beg /.well-known/acme-challenge/
use_backend letsencrypt_backend if letsencrypt_challenge
redirect scheme https code 301 if !letsencrypt_challenge
frontend https
mode http
bind *:443 ssl crt /certs/combined.pem
option httplog
redirect location /docs/ if { path_reg -i ^/docs$ }
acl is_options method OPTIONS
acl is_http path_beg /api/incomingData /api/actilityIntegration/readings /api/incomingLora
acl is_api path_beg /api
acl is_docs path_beg /docs
use_backend cors if is_options
use_backend http2amqp if is_http
use_backend appserver if is_api
use_backend docs if is_docs
use_backend frontend
backend letsencrypt_backend
mode http
server certbot certbot:9999 # Certbot listens on this port
backend appserver
mode http
http-response set-header Access-Control-Allow-Origin api-example.com
balance roundrobin
server appserver backend:8080 check inter 5000
backend http2amqp
mode http
http-response set-header Access-Control-Allow-Origin api-example.com
balance roundrobin
compression algo gzip
compression offload
server http http2amqp:8080 check inter 5000
backend docs
mode http
http-response set-header Access-Control-Allow-Origin api-example.com
http-request replace-path /docs([/]?)(.*) /\2
balance roundrobin
server docs #{PRIV_IP}:1337 check inter 5000
backend frontend
mode http
http-response set-header Access-Control-Allow-Origin api-example.com
balance roundrobin
server apache frontend:80 check inter 5000
backend cors
mode http
errorfile 503 /etc/haproxy/options.http
TEXT
Text Only
HTTP/1.1 200 OK
Access-Control-Allow-Headers: Origin, Accept, X-Session_id, Content-Type, x-requested-with, Content-Type, Authorization, client-security-token
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
Access-Control-Max-Age: 1000
Access-Control-Allow-Methods: HEAD, DELETE, POST, GET, OPTIONS, PUT
Connection: close```