`
sillycat
  • 浏览: 2552519 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

2018 Raspberry Pi and HaProxy

 
阅读更多
2018 Raspberry Pi and HaProxy

I will fetch the latest Haproxy
>wget http://www.haproxy.org/download/1.8/src/haproxy-1.8.4.tar.gz

https://linuxacademy.com/howtoguides/posts/show/topic/13169-installation-of-haproxy
Unzip that file and use make compile to build
>make TARGET=linux2628
>sudo make install

Set up the Mysql(MariaDB)
http://sillycat.iteye.com/blog/2393787

Here is the set up for my current Haproxy Docker Configuration
Makefile
IMAGE=sillycat/public
TAG=raspberrypi-haproxy
NAME=raspberrypi-haproxy

docker-context:

build: docker-context
docker build -t $(IMAGE):$(TAG) .

run:
docker run -d -p 80:80 -p 3306:3306 --name $(NAME) $(IMAGE):$(TAG)

debug:
docker run -ti -p 80:80 -p 3306:3306 --name $(NAME) $(IMAGE):$(TAG) /bin/bash

clean:
docker stop ${NAME}
docker rm ${NAME}

logs:
docker logs ${NAME}

publish:
docker push ${IMAGE}:${TAG}

fetch:
docker pull ${IMAGE}:${TAG}

start.sh to start the Process
#!/bin/sh -ex

#start the haproxy
cd /tool/haproxy-1.8.4
haproxy -f conf/haproxy.conf

Here comes the most important file Dockerfile
#Set up haproxy in Docker

#Prepre the OS
FROM resin/rpi-raspbian:jessie
MAINTAINER Carl Luo <luohuazju@gmail.com>

ENV DEBIAN_FRONTEND noninteractive
RUN apt-get -y update
RUN apt-get install -y apt-utils
RUN apt-get -y dist-upgrade
RUN apt-get install -y build-essential gcc make
RUN apt-get install -y libpcre3 libpcre3-dev zlib1g-dev libgcrypt11-dev

#install haproxy
RUN     mkdir -p /tool
RUN     mkdir -p /install
ADDinstall/haproxy-1.8.4.tar.gz /install/
WORKDIR /install/haproxy-1.8.4
RUN     make TARGET=linux2628
RUN     make install

#config haproxy
RUN     mkdir -p /tool/haproxy-1.8.4/conf
ADD     conf/haproxy.conf /tool/haproxy-1.8.4/conf/
RUN     mkdir -p /var/lib/haproxy

#start the application
EXPOSE  80 3306
RUN     mkdir -p /app/
ADD     start.sh /app/
WORKDIR /app/
CMD[ "./start.sh" ]

I plan to support 2 different websites which host static resources, and one proxy to my backend MySQL in conf/haproxy.conf
global
maxconn     400
#daemon

defaults
timeout connect         30000
timeout client          50000
timeout server          50000

stats enable
stats hide-version
stats uri     /stats
stats auth    useradmin:xxxxx

frontend http-in
bind *:80
mode http
acl url_water       path_beg       -i /water
acl url_price       path_beg       -i /price

use_backend web_water          if url_water
default_backend web_price

backend web_water
        mode http
balance roundrobin
server web_water1 192.168.1.108:8081 check

backend web_price
mode http
balance roundrobin
server web_price1 192.168.1.108:8081 check

listen mysql
      bind *:3306      
      mode      tcp     
      balance roundrobin      
      server mysql2  192.168.1.109:3306 check

Then we can visit the proxy status page as follow:
http://192.168.1.108/stats

Static Website 1
http://192.168.1.108/water/

Static Website 2
http://192.168.1.108/price/

References:
http://www.haproxy.org/
http://sillycat.iteye.com/blog/1055846
http://sillycat.iteye.com/blog/2066118
http://sillycat.iteye.com/blog/562645
http://sillycat.iteye.com/blog/1055846
http://sillycat.iteye.com/blog/2066119

http://liaoph.com/haproxy-tutorial/



分享到:
评论

相关推荐

    Beginning Robotics with Raspberry Pi and Arduino_Using Python and OpenCV

    Beginning Robotics with Raspberry Pi and Arduino_Using Python and OpenCV-Apress(2018) Robotics does not have to be difficult. In this book, I introduce you to the field of robotics. The journey will ...

    Raspberry.Pi.Home.Automation.with.Arduino.2nd.Edition.178439

    Revolutionize the way you interact with your home and become part of the rapidly growing group of hobbyists and enthusiasts by combining the powerful Raspberry Pi with an Arduino board. Starting with...

    Raspberry Pi 4 Beginner’s Guide.pdf

    介绍Raspberry Pi 4的用户手册,值得一读。 In our opinion, you will certainly adore the Raspberry Pi 4. Ultra-small, affordable, even cheaper than most video games, you can use the Pi to build ...

    Raspberry Pi Zero Cookbook

    The Raspberry Pi Zero, one of the most inexpensive, fully-functional computers available, is a powerful and revolutionary product developed by the Raspberry Pi Foundation. The Raspberry Pi Zero opens ...

    Raspberry Pi Cookbook.pdf

    The world of Raspberry Pi is evolving quickly, with many new interface boards and software libraries becoming available all the time. In this cookbook, prolific hacker and author Simon Monk provides ...

    Raspberry Pi

    MEDIA CENTER WITH XBMC AND RASPBERRY PI 2 MINIATURE BALLOON MINECRAFT SERVER RUNNING ON RASPBERRY PI 2 CHAPTER 3: USING THE RASPBERRY PI 2FOR YOUR PROJECT DIFFERENCES BETWEEN THE ARDUINO BOARD AND ...

    Wiley Learning Python with Raspberry Pi 2014

    《Wiley Learning Python with Raspberry Pi 2014》是一本专为初学者设计的教程,旨在引导读者通过树莓派这一小型计算机平台学习Python编程。这本书由2014年出版,当时Python已是编程界的热门语言,而树莓派因其低...

    Advanced Raspberry Pi Raspbian Linux and GPIO Integration.zip

    You'll work with Linux driver information and explore the different Raspberry Pi models, including the Pi Zero, Pi Zero W, Pi 2, Pi3 B and Pi3 B+. You'll also review a variety of project examples ...

    Raspberry Pi Supercomputing and Scientific Programming

    使用Raspberry Pi 进行这些活动可能会有局限性,因为它们的处理能力并不足以匹敌真正的超级计算机,但是通过使用多个 Raspberry Pi 组成集群,可以实现并行计算来提高处理速度。Raspberry Pi 集群可以执行一些计算...

    Raspberry Pi LED Blueprints(PACKT,2015)

    By customizing and utilising LED-based modules into the Raspberry Pi board, exciting projects can be obtained. A countdown timer, a digital clock, a traffic light controller, and a remote light ...

    Getting Started with Raspberry Pi Zero.pdf

    Get started with Raspberry Pi Zero and put all of its exciting features to use Create fun games and programs with little or no programming experience Learn to use this super-tiny PC to control ...

    Raspberry.Pi.Computer.Architecture.Essentials.17843

    Explore Raspberry Pi 2's hardware through the Assembly, C/C++, and Python programming languages Experiment with connecting electronics up to your Raspberry Pi 2 and interacting with them through ...

    Raspberry Pi Networking Cookbook(PACKT,2ed,2016)

    With increasing interest in Maker Projects and the Internet of Things (IoT), students, scientists, and hobbyists are using the Raspberry Pi as a reliable, inexpensive platform to connect local devices...

Global site tag (gtag.js) - Google Analytics