Single-node Nginx provides load balancing for two Apache servers (reprint)

Source: Internet
Author: User

Single-node Nginx provides load balancing for two Apache servers

Requirements: This experiment provides load balancing for two Apache servers for single-node Nginx, all configured as the simplest

1. Initialize 3 test server, the off

123456789 [[email protected] ~] # vim/etc/hosts Code class= "Bash plain" >192.168.1.101   ng-master 192.168.1.161    WEB1 192.168.1.162   web2  [ [email protected] ~] # yum clean all [[email  protected] ~] # systemctl stop Firewalld.service [[email protected] ~] # systemctl disable Firewalld.service [[email protected] ~] # sed-i "s/selinux=enforcing/selinux=disabled/g"/etc/selinux/config

2. Configure Apache Services for WEB1,WEB2

123456 [[email protected] ~]# yum -y install httpd[[email protected] ~]# systemctl start httpd[[email protected] ~]# systemctl enable httpdln-s ‘/usr/lib/systemd/system/httpd.service‘‘/etc/systemd/system/multiuser.target.wants/httpd.service‘[[email protected] ~]# cat /var/www/html/index.htmlhello this lvs-web1

3. Configuring Nginx nodes with Yum installation

12345678910111213141516171819202122232425262728 [[email protected] ~]# vim /etc/yum.repos.d/nginx.repo[nginx]name=nginx repobaseurl=http://nginx.org/packages/centos/7/x86_64/gpgcheck=0enabled=1[[email protected] ~]# yum clean all[[email protected] ~]# yum -y install nginx[[email protected] ~]# vim /usr/share/nginx/html/index.html/h1>[[email protected] ~]# cd /etc/nginx/conf.d/[[email protected] conf.d]# mv default.conf default.conf.1[[email protected] ~]# vim /etc/nginx/conf.d/web.conf    upstream myapp1 {        server web1;        server web2;    }    server {        listen 80;        location / {            proxy_pass http://myapp1;        }    }[[email protected] ~]# systemctl restart nginx.service

4. View Nginx related logs

123 [[email protected] conf.d]# tail -f /var/log/messages[[email protected] conf.d]# tail -f /var/log/nginx/access.log[[email protected] conf.d]# tail -f /var/log/nginx/error.log

5. Access test http://192.168.1.101/via browser or http://myapp1/to discover traffic between Web1 and WEB2 jumps

Reference:

Http://www.linuxdiyf.com/linux/12955.html
Http://nginx.org/en/linux_packages.html
http://blog.csdn.net/e421083458/article/details/30086413

Single-node Nginx provides load balancing for two Apache servers (reprint)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.