Pada kesempatan kali ini kami akan berbagi bagaimana cara compile HAProxy 2.0 Pada CentOS.

Kenapa harus di compile?

Karena default repositori yang tersedia untuk HAProxy pada CentOS 7 yaitu versi 1.5. Dengan demikian bila Anda ingin menggunakan versi 2.0 Pada CentOS 7 salah satu nya cara yaitu compile.

Berikut ini tahapan compile HAProxy 2.0 pada CentOS 7.

  1. Silakan akses server CentOS 7 Anda masing - masing
  2. Melakukan update gunakan perintah berikut

    [[email protected] ~]#
    [[email protected] ~]# yum update -y
    
  3. Instalasi dependencies yang dibutuhkan

    [[email protected] ~]#
    [[email protected] ~]# yum install gcc pcre-static pcre-devel openssl-devel tar make -y
    

    Silakan tunggu proses instalasinya sampai selesai

  4. Unduh HAProxy 2.0 melalui link berikut: Download page atau Anda dapat menggunakan wget sebagai berikut

    [[email protected] ~]#
    [[email protected] ~]# wget http://www.haproxy.org/download/2.0/src/haproxy-2.0.7.tar.gz -O ~/haproxy.tar.gz
    --2019-11-16 19:58:09--  http://www.haproxy.org/download/2.0/src/haproxy-2.0.7.tar.gz
    Resolving www.haproxy.org (www.haproxy.org)... 51.15.8.218
    Connecting to www.haproxy.org (www.haproxy.org)|51.15.8.218|:80... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 2542573 (2.4M) [application/x-tar]
    Saving to: '/root/haproxy.tar.gz'
    
    100%[=======================================================================================>] 2,542,573   1.25MB/s   in 1.9s   
    
    2019-11-16 19:58:12 (1.25 MB/s) - '/root/haproxy.tar.gz' saved [2542573/2542573]
    
    [[email protected] ~]#
    
  5. Ekstrack file yang telah di unduh

    [[email protected] ~]#
    [[email protected] ~]# tar xzvf ~/haproxy.tar.gz -C ~/
    
  6. Pindah ke direktori hasil extrack

    [[email protected] ~]#
    [[email protected] ~]# cd ~/haproxy-2.0.7/
    [[email protected] haproxy-2.0.7]#
    
  7. Compile HAProxy gunakan perintah berikut

    [[email protected] haproxy-2.0.7]#
    [[email protected] haproxy-2.0.7]# make TARGET=linux-glibc
    CC      src/ev_poll.o
    CC      src/ev_epoll.o
    CC      src/namespace.o
    CC      src/proto_http.o
    CC      src/cfgparse-listen.o
    CC      src/proto_htx.o
    CC      src/stream.o
    CC      src/mux_h2.o
    CC      src/stats.o
    CC      src/flt_spoe.o
    CC      src/server.o
    CC      src/checks.o
    CC      src/haproxy.o
    CC      src/cfgparse.o
    CC      src/flt_http_comp.o
    CC      src/http_fetch.o
    CC      src/dns.o
    CC      src/stick_table.o
    CC      src/mux_h1.o
    CC      src/peers.o
    CC      src/standard.o
    CC      src/proxy.o
    CC      src/cli.o
    CC      src/log.o
    CC      src/backend.o
    CC      src/pattern.o
    CC      src/sample.o
    CC      src/stream_interface.o
    CC      src/proto_tcp.o
    CC      src/listener.o
    CC      src/h1.o
    CC      src/cfgparse-global.o
    CC      src/cache.o
    CC      src/http_rules.o
    CC      src/http_act.o
    CC      src/tcp_rules.o
    CC      src/filters.o
    CC      src/connection.o
    CC      src/session.o
    CC      src/acl.o
    CC      src/vars.o
    CC      src/raw_sock.o
    CC      src/map.o
    CC      src/proto_uxst.o
    CC      src/payload.o
    CC      src/fd.o
    CC      src/queue.o
    CC      src/flt_trace.o
    CC      src/task.o
    CC      src/lb_chash.o
    CC      src/frontend.o
    CC      src/applet.o
    CC      src/mux_pt.o
    CC      src/signal.o
    CC      src/ev_select.o
    CC      src/proto_sockpair.o
    CC      src/compression.o
    CC      src/http_conv.o
    CC      src/memory.o
    CC      src/lb_fwrr.o
    CC      src/channel.o
    CC      src/htx.o
    CC      src/uri_auth.o
    CC      src/regex.o
    CC      src/chunk.o
    CC      src/pipe.o
    CC      src/lb_fas.o
    CC      src/lb_map.o
    CC      src/lb_fwlc.o
    CC      src/auth.o
    CC      src/time.o
    CC      src/hathreads.o
    CC      src/http_htx.o
    CC      src/buffer.o
    CC      src/hpack-tbl.o
    CC      src/shctx.o
    CC      src/sha1.o
    CC      src/http.o
    CC      src/hpack-dec.o
    CC      src/action.o
    CC      src/proto_udp.o
    CC      src/http_acl.o
    CC      src/xxhash.o
    CC      src/hpack-enc.o
    CC      src/h2.o
    CC      src/freq_ctr.o
    CC      src/lru.o
    CC      src/protocol.o
    CC      src/arg.o
    CC      src/hpack-huff.o
    CC      src/hdr_idx.o
    CC      src/base64.o
    CC      src/hash.o
    CC      src/mailers.o
    CC      src/activity.o
    CC      src/http_msg.o
    CC      src/version.o
    CC      src/mworker.o
    CC      src/mworker-prog.o
    CC      src/debug.o
    CC      src/wdt.o
    CC      src/dict.o
    CC      src/xprt_handshake.o
    CC      ebtree/ebtree.o
    CC      ebtree/eb32sctree.o
    CC      ebtree/eb32tree.o
    CC      ebtree/eb64tree.o
    CC      ebtree/ebmbtree.o
    CC      ebtree/ebsttree.o
    CC      ebtree/ebimtree.o
    CC      ebtree/ebistree.o
    LD      haproxy
    [[email protected] haproxy-2.0.7]# 
    
  8. Setelah berhasil di compile silakan install HAProxy dengan cara menjalankan perintah

    [[email protected] haproxy-2.0.7]#
    [[email protected] haproxy-2.0.7]# make install
    'haproxy' -> '/usr/local/sbin/haproxy'
    'doc/haproxy.1' -> '/usr/local/share/man/man1/haproxy.1'
    install: creating directory '/usr/local/doc'
    install: creating directory '/usr/local/doc/haproxy'
    'doc/configuration.txt' -> '/usr/local/doc/haproxy/configuration.txt'
    'doc/management.txt' -> '/usr/local/doc/haproxy/management.txt'
    'doc/seamless_reload.txt' -> '/usr/local/doc/haproxy/seamless_reload.txt'
    'doc/architecture.txt' -> '/usr/local/doc/haproxy/architecture.txt'
    'doc/peers-v2.0.txt' -> '/usr/local/doc/haproxy/peers-v2.0.txt'
    'doc/regression-testing.txt' -> '/usr/local/doc/haproxy/regression-testing.txt'
    'doc/cookie-options.txt' -> '/usr/local/doc/haproxy/cookie-options.txt'
    'doc/lua.txt' -> '/usr/local/doc/haproxy/lua.txt'
    'doc/WURFL-device-detection.txt' -> '/usr/local/doc/haproxy/WURFL-device-detection.txt'
    'doc/proxy-protocol.txt' -> '/usr/local/doc/haproxy/proxy-protocol.txt'
    'doc/linux-syn-cookies.txt' -> '/usr/local/doc/haproxy/linux-syn-cookies.txt'
    'doc/SOCKS4.protocol.txt' -> '/usr/local/doc/haproxy/SOCKS4.protocol.txt'      
    'doc/network-namespaces.txt' -> '/usr/local/doc/haproxy/network-namespaces.txt'
    'doc/DeviceAtlas-device-detection.txt' -> '/usr/local/doc/haproxy/DeviceAtlas-device-detection.txt'
    'doc/51Degrees-device-detection.txt' -> '/usr/local/doc/haproxy/51Degrees-device-detection.txt'    
    'doc/netscaler-client-ip-insertion-protocol.txt' -> '/usr/local/doc/haproxy/netscaler-client-ip-insertion-protocol.txt'
    'doc/peers.txt' -> '/usr/local/doc/haproxy/peers.txt'
    'doc/close-options.txt' -> '/usr/local/doc/haproxy/close-options.txt'
    'doc/SPOE.txt' -> '/usr/local/doc/haproxy/SPOE.txt'
    'doc/intro.txt' -> '/usr/local/doc/haproxy/intro.txt'
    [[email protected] haproxy-2.0.7]#
    
  9. Saat ini instalasi HAProxy telah selesai dilakukan, selanjutnya melakukan konfigurasi tambahan supaya HAProxy dapat berjalan dengan sempurna. Silakan buat beberapa direktori sebagai berikut:

    [[email protected] haproxy-2.0.7]# 
    [[email protected] haproxy-2.0.7]# mkdir -p /etc/haproxy
    [[email protected] haproxy-2.0.7]# mkdir -p /var/lib/haproxy
    [[email protected] haproxy-2.0.7]# mkdir -p /var/lib/haproxy/stats
    [[email protected] haproxy-2.0.7]# 
    
  10. Membuat symlink HAProxy untuk dapat berjalan gunakan perintah

    [[email protected] haproxy-2.0.7]# ln -s /usr/local/sbin/haproxy /usr/sbin/haproxy
    [[email protected] haproxy-2.0.7]# 
    
  11. Jika Anda ingin menambahkan proxy sebagai service ke sistem, copy file haproxy.init ke direktori /etc/init.d Anda. Ubah permission file supaya script dapat dieksekusi dan kemudian muat ulang daemon systemd.

    [[email protected] haproxy-2.0.7]#
    [[email protected] haproxy-2.0.7]# cp ~/haproxy-2.0.7/examples/haproxy.init /etc/init.d/haproxy
    [[email protected] haproxy-2.0.7]# chmod 755 /etc/init.d/haproxy
    [[email protected] haproxy-2.0.7]# systemctl daemon-reload
    [[email protected] haproxy-2.0.7]# 
    
  12. Supaya HAProxy dapat aktif secara otomatis apabila server di restart jalankan perintah berikut

    [[email protected] haproxy-2.0.7]# systemctl enable haproxy 
    haproxy.service is not a native service, redirecting to /sbin/chkconfig.
    Executing /sbin/chkconfig haproxy on
    [[email protected] haproxy-2.0.7]# 
    [[email protected] haproxy-2.0.7]# chkconfig haproxy on
    [[email protected] haproxy-2.0.7]# 
    
  13. Membuat user haproxy

    [[email protected] haproxy-2.0.7]# useradd -r haproxy 
    [[email protected] haproxy-2.0.7]# 
    
  14. Jika ingin melihat versi HAProxy jalankan perintah

    [[email protected] haproxy-2.0.7]# haproxy -v
    HA-Proxy version 2.0.7 2019/09/27 - https://haproxy.org/
    [[email protected] haproxy-2.0.7]#
    
  15. Hasil compile berbeda dengan hasil instalasi menggunakan repo, hasil compile Anda dapat membuat secara mandiri file haproxy.cfg nya. Jika Anda install menggunakan repo secara default sudah tersedia configurasi defaultnya di direktori /etc/haproxy/

Sekian panduan terkait compile HAProx 2.0 di CentOS 7.

Selamat belajar semoga bermanfaat.

See You >.<