Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save unchama/11277ce0ce6d3a0b4722afd8dd64461f to your computer and use it in GitHub Desktop.
Save unchama/11277ce0ce6d3a0b4722afd8dd64461f to your computer and use it in GitHub Desktop.
#---------------------------------------------------------------------
# Example configuration for a possible web application. See the
# full configuration options online.
#
# http://haproxy.1wt.eu/download/1.4/doc/configuration.txt
#
#---------------------------------------------------------------------
#---------------------------------------------------------------------
# Global settings
#---------------------------------------------------------------------
global
# to have these messages end up in /var/log/haproxy.log you will
# need to:
#
# 1) configure syslog to accept network log events. This is done
# by adding the '-r' option to the SYSLOGD_OPTIONS in
# /etc/sysconfig/syslog
#
# 2) configure local2 events to go to the /var/log/haproxy.log
# file. A line like the following can be added to
# /etc/sysconfig/syslog
#
# local2.* /var/log/haproxy.log
#
log 127.0.0.1 local2
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 4000
user haproxy
group haproxy
daemon
# turn on stats unix socket
stats socket /var/lib/haproxy/stats
#---------------------------------------------------------------------
# gateway server settings
#---------------------------------------------------------------------
defaults
log global
mode http
option httplog
option dontlognull
timeout connect 5000
timeout client 50000
timeout server 50000
#---------------------------------------------------------------------
# http gateway
#---------------------------------------------------------------------
frontend http_web
bind 0.0.0.0:80
capture request header X-Forwarded-For len 50
option forwardfor
acl frontend01 hdr(host) -i <DomainAddress(ex: www.example.com)>
use_backend backend01 if frontend01
backend backend01
server dynmap <DestinationIP>:<DestinationPort> cookie A check
#---------------------------------------------------------------------
# minecraft server gateway
#---------------------------------------------------------------------
listen minecraftsv01
bind 0.0.0.0:25565
mode tcp
option tcplog
balance roundrobin
server mc01 <DestinationIP>:<DestinationPort> send-proxy-v2
# please rename to Dockerfile
FROM haproxy:latest
ENV HAPROXY_USER haproxy
RUN groupadd --system ${HAPROXY_USER} && \
useradd --system --gid ${HAPROXY_USER} ${HAPROXY_USER} && \
mkdir --parents /var/lib/${HAPROXY_USER} && \
chown -R ${HAPROXY_USER}:${HAPROXY_USER} /var/lib/${HAPROXY_USER}
CMD ["haproxy", "-db", "-f", "/usr/local/etc/haproxy/haproxy.cfg"]
# please rename to docker-compose.yml
version: '3.3'
networks:
haproxy-network:
external: false
services:
haproxy:
build: .
#常時起動にするなら以下のコメントアウトを外す(docker自体の常駐化も忘れずに)
#restart: always
environment:
- TZ=Asia/Tokyo
networks:
- haproxy-network
ports:
- "80:80/tcp"
- "25565:25565/tcp"
volumes:
- ./haproxy.cfg.default:/usr/local/etc/haproxy/haproxy.cfg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment