1024programmer Nginx Install and configure nginx under CentOS to do load balancing for IIS servers

Install and configure nginx under CentOS to do load balancing for IIS servers

1. Environment preparation
Install CentOS version: 6.2
Nginx version: 1.2.1

2. Introduction to common Linux commands
If a worker wants to do a good job, he must first sharpen his tools. Before operating the Linux system, we must master some basic commands. I believe that people who have used DOS will not be too unfamiliar, basically including windows and linux. The command line mode is developed from the unix system. Here are just a few commands that will be involved in this blog. For more introduction, please refer to the relevant information.

ls Used to display files and directories under a certain path For example: ls -a
cd Enter a directory or return to the parent directory For example: cd /directory; cd ..
ps show process information For example: ps -ef | grep nginx
mkdir Create a directory For example: mkdir yourdir
rmdir delete directory the
rm Delete Files the
kill end process For example: kill -TERM pid sends a term signal to the parent process, killing the process and the child process
log out log out of the current session the
reboot restart the system the
yum Install related toolkits the
setup Configure network and firewall settings the
vi vim text editor For example: vi /usr/local/nginx/conf/nginx.conf


3. Install Nginx

After completing the installation of centos, use the root user to enter the system, and use wget to install the nginx package
wget http://www.nginx.org/download/nginx-1.2.1.tar.gz
Unzip the package
tar -zxvf nginx-1.2.1.tar.gz
Install the gcc compiler and related tools
yum -y install gcc gcc-c++ autoconf automake
make
Install dependent modules
yum -y install zlib zlib-devel openssl openssl –devel
pcre pcre-devel
Install by compiling the source code:
./configure
Execute command:
make
Execute command:
make install

Fourth, configure Nginx
Example configuration file:

Configuration file description:
nginx server as front-end reverse proxy
Configure two IISs on the backend as split servers
Load method based on ip-hash
Test configuration file for errors:
/$your directory/nginx/sbin/nginx -t

Five, how to start Nginx

Directly execute the file to start:
# /usr/local/nginx/sbin/nginx
After the startup is successful, check the nginx process information:
# ps -ef | grep nginx
See if there is an nginx process to confirm whether it is successfully started. At the same time, remember to check the centos firewall settings, whether the corresponding port is opened, you can use the setup command to set the firewall, dns, network and other information. If the default configuration file has not been changed, use the browser to directly access nginx
server, a prompt will appear: Welcome to Nginx

6. Summary

According to the above steps, the test environment has been established, nginx can proxy the front-end requests very well, and shunt them to the back-end IIS, Session, COOKIE, etc. seem to be fine. Detailed testing is still in progress, if there are no problems, we will use it in a formal production environment. There is nothing wrong with using the excellent software under Linux to serve the .Net system!

This article is from the internet and does not represent1024programmerPosition, please indicate the source when reprinting:https://www.1024programmer.com/install-and-configure-nginx-under-centos-to-do-load-balancing-for-iis-servers/

author: admin

Previous article
Next article

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索