Installing haproxy load balancing for http and https--转载
2013-11-04 21:58
337 查看
This example will guide you through a simple IP based load balancing solution that handles ssl traffic.
The Configuration =
Load Balancer: <192.168.0.2> // will be our haproxy server
Web Server 1: <192.168.0.10> // web application server 1
Web Server 2: <192.168.0.20> // web application server 2
Admin Panel Port 8080: <192.168.0.2> // Statistics Panel on port 8080
Web Server 1
Load Balancer <
Web Server 2
wget http://haproxy.1wt.eu/download/1.3/src/haproxy-1.3.17.tar.gz
cd haproxy-1.3.17
make TARGET=linux26
cp /path/to/haproxy-1.3.17/examples/haproxy.init /etc/init.d/haproxy
chmod +x /etc/init.d/haproxy
Step 2: Create some users for security
We’re going to add a haproxy user and run it in a chroot jail. Be sure to read up on other security measures for your server.
useradd haproxy
mkdir /var/chroot/haproxy
chown haproxy:haproxy /var/chroot/haproxy
chmod 700 /var/chroot/haproxy
Step 3: Configure /etc/haproxy.cfg
This will be a simple load balancing. The HAProxy server will listen to 1 IP and distribute to 2 servers.
global
maxconn 10000 # Total Max Connections.
log 127.0.0.1 local0
log 127.0.0.1 local1 notice
daemon
nbproc 1 # Number of processes
user haproxy
group haproxy
chroot /var/chroot/haproxy
defaults
log global
option httplog
mode tcp
clitimeout 60000
srvtimeout 30000
contimeout 4000
retries 3
redispatch
option httpclose
listen load_balanced 192.168.0.2:80,192.168.0.2:443
balance source
option ssl-hello-chk
option forwardfor
server webserver1 192.168.0.10 weight 1 maxconn 5000 check
server webserver2 192.168.0.20 weight 1 maxconn 5000 check
listen admin_stats 192.168.0.2:8080
mode http
stats uri /my_stats
stats realm Global\ statistics
stats auth username:password
SYSLOGD_OPTIONS=”-m 0 -r”
Edit /etc/syslog.conf. Add the following:
local0.* /var/log/haproxy.log
local1.* /var/log/haproxy-1.log
service syslog restart
The Configuration =
Load Balancer: <192.168.0.2> // will be our haproxy server
Web Server 1: <192.168.0.10> // web application server 1
Web Server 2: <192.168.0.20> // web application server 2
Admin Panel Port 8080: <192.168.0.2> // Statistics Panel on port 8080
Web Server 1
Load Balancer <
Web Server 2
Step 1: Get and Install haproxy
We’ll be using the 1.3.17 src files to install haproxy. You can get them from http://haproxy.1wt.eu/wget http://haproxy.1wt.eu/download/1.3/src/haproxy-1.3.17.tar.gz
cd haproxy-1.3.17
make TARGET=linux26
cp /path/to/haproxy-1.3.17/examples/haproxy.init /etc/init.d/haproxy
chmod +x /etc/init.d/haproxy
Step 2: Create some users for security
We’re going to add a haproxy user and run it in a chroot jail. Be sure to read up on other security measures for your server.
useradd haproxy
mkdir /var/chroot/haproxy
chown haproxy:haproxy /var/chroot/haproxy
chmod 700 /var/chroot/haproxy
Step 3: Configure /etc/haproxy.cfg
This will be a simple load balancing. The HAProxy server will listen to 1 IP and distribute to 2 servers.
global
maxconn 10000 # Total Max Connections.
log 127.0.0.1 local0
log 127.0.0.1 local1 notice
daemon
nbproc 1 # Number of processes
user haproxy
group haproxy
chroot /var/chroot/haproxy
defaults
log global
option httplog
mode tcp
clitimeout 60000
srvtimeout 30000
contimeout 4000
retries 3
redispatch
option httpclose
listen load_balanced 192.168.0.2:80,192.168.0.2:443
balance source
option ssl-hello-chk
option forwardfor
server webserver1 192.168.0.10 weight 1 maxconn 5000 check
server webserver2 192.168.0.20 weight 1 maxconn 5000 check
listen admin_stats 192.168.0.2:8080
mode http
stats uri /my_stats
stats realm Global\ statistics
stats auth username:password
Step 4: Configuring logging
Edit /etc/sysconfig/syslogSYSLOGD_OPTIONS=”-m 0 -r”
Edit /etc/syslog.conf. Add the following:
local0.* /var/log/haproxy.log
local1.* /var/log/haproxy-1.log
Restart Syslog
service syslog restart
相关文章推荐
- Installing haproxy load balancing for http and https--转载
- How to Configure Tomcat/JBoss and Apache HTTPD for Load Balancing and Failover
- nodejs报错 XMLHttpRequest cannot load localhost:3000/test_date/. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.
- Creating CustomBinding for WCFBasicHTTP for SSL and BasicAuthentication in BizTalk 转载自:http://geekswithblogs.net/mipsen
- install mongrel for rails and apache http for load balance
- 2. HTTP load-balancing with cookie prefixing and high availability
- HTTP Handler to Combine Multiple Files, Cache and Deliver Compressed Output for Faster Page Load
- Highly Available L7 Load Balancing for Exchange 2013 with HAProxy – Par
- A Load Balancing, Monitoring and AutoScaling Solution for Private Clouds Using AWS APIs
- 3. Simple HTTP/HTTPS load-balancing with cookie insertion
- How to Configure Tomcat/JBoss and Apache HTTPD for Load Balancing and Failover
- 通过url获取远程文件(for http and https)
- jquery读取本地文件,Windows上报错。XMLHttpRequest cannot load xxx. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.k.cors.a.c
- HTTP Status 404 - No result defined for action and result input
- [转载]10 Best Tools For Websites And Apps Development Ever
- “HTTP Status 404 - No result defined for action ****** and result result”错误解决方法
- HTTP Status 404 There is no Action mapped for namespace / and action name
- What is the Difference Between http and https?
- 【Google Chrome】 Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource问题解决
- 【HTTP】Speed and Mobility: An Approach for HTTP 2.0 to Make Mobile Apps and the Web Faster