In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to configure nginx reverse proxy load balancing cluster under centos7. The content of this article is of high quality, so the editor will share it with you for reference. I hope you will have some understanding of the relevant knowledge after reading this article.
Nginx is a web server, similar to apache, but better and faster than apache. It can also implement reverse proxy and load balancing, which is often used to build load balancing for web service clusters. Today, let's record the installation and configuration of nginx to achieve the role of load balancing.
Experimental environment:
192.168.1.188 nginx load balancer
192.168.1.189 web01 Server
192.168.1.190 web02 Server
Software preparation:
Centos7.4 x86_64
Nginx-1.6.3.tar.gz
Install nginx softwar
Install a collection of dependent package commands
[root@localhost ~] # yum-y install openssl openssl-devel pcre pcre-devel gcc
Install nginx package command collection
[root@localhost ~] # mkdir / app [root@localhost ~] # cd / app [root@localhost ~] # wget-Q http://nginx.org/download/nginx-1.6.3.tar.gz[root@localhost ~] # useradd-s / sbin/nologin-M [root@localhost ~] # tar xf nginx-1.6.3.tar.gz [root@localhost ~] # cd nginx-1.6.3 [root@localhost] #. / configure-- user=nginx-- group=nginx- -prefix=/app/nginx-- with-http_stub_status_module-- with-http_ssl_ module [root @ localhost ~] # make & & make install
Configuration file
(the following is done on web01 and web02)
[root@localhost ~] # vim / app/nginx/conf/nginx.conf
Modify the configuration file to
Worker_processes 1 status events {worker_connections 1024;} http {listen 65 × logarithmic format main'$remote_addr-$remote_user [$time_local] "$request"'$status $body_bytes_sent "http_referer"''"$http_user_agent"$http_x_forwarded_for"; server {listen 80 / serveraccounname bbs.dengchuanghai.org;location / {root html/bbs;index index.html index.htm } access_log logs/access_bbs.log main }} [root@localhost ~] # mkdir / app/nginx/html/bbs [root@localhost ~] # echo "192.168.1.189 bbs" > > / app/nginx/html/bbs/index.html [root@localhost ~] # echo "192.168.1.189 bbs.dengchuanghai.org" > > / etc/hosts [root@localhost ~] # echo "192.168.1.190 bbs" > > / app/nginx/html/bbs/ Index.html [root@localhost ~] # echo "192.168.1.190 bbs.dengchuanghai.org" > > / etc/hosts
(enter the above on two web servers)
Then start nginx separately
[root@localhost ~] # / app/nginx/sbin/nginx-t (check the configuration file for errors) [root@localhost ~] # / app/nginx/sbin/nginx launch [root@localhost ~] # ss-tnlp | grep 80
Use curl bbs.dengch
The following operations are performed on the nginx load balancer
[root@localhost ~] # vim / app/nginx/conf/nginx.conf
Change to the following
Worker_processes 1 server events {worker_connections 1024;} http {include mime.types;default_type application/octet-stream;sendfile on;keepalive_timeout 65 scene upstream www_server_pools {server 192.168.1.190 weight=1;server 80 weight=1;server 192.168.1.189 worker_connections} server {listen 80 weight=1; www.dengchuanghai.org;location / {proxy_pass events ~] # echo "192.168.1.188 www.dengchuanghai,org" > > / etc/hosts
Check the grammar
[root@localhost] # / app/nginx/sbin/nginx-t
Start the service
[root@localhost ~] # / app/nginx/sbin/nginx
Use curl www.dengchuanghai.org
It is found that the output of the result is the rotation of the two servers.
The experiment is over
This is the end of how to configure nginx reverse proxy load balancing cluster under centos7. I hope the above content can be of some help and learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.