In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
The following brings you why to use Nginx reasons, reverse proxy and load balancing configuration process, hoping to give you some help in practical application. Load balancing involves more things, there are not many theories, and there are many books on the Internet. Today, we will use the accumulated experience in the industry to do an answer.
[1. Why use nginx]
To answer why you use nginx, first talk about what nginx can do.
First of all, nginx can do reverse proxy, so what is reverse proxy? for example, I want to use the domain name of www.mickey.com to access www.taobao.com locally. Then we can achieve it through nginx at this time.
In addition, nginx can achieve load balancing, what is load balancing? My project is deployed on different CVMs, but through a unified domain name, nginx distributes the requests, reducing the pressure on the server.
In both cases, the nginx server only acts as a distributor, and we can put the real content on other servers, so that it can also act as a layer of security next door, and nginx as an isolation layer.
Second, nginx can also solve cross-domain problems.
[II. Nginx installation]
Download the corresponding version of nginx at http://nginx.org/
Use start nginx in the nginx directory or double-click nginx.exe to open nginx
[III. Description of nginx configuration attributes]
# Global setting-1 worker_connections nginx Multiplexing), but only for kernels above default_type application/octet-stream, it can greatly improve the performance of Ginx nginx. / var/log/nginx//O processing speed to slow down the system's uptime.65 "MSIE [1-6]\. (?!. * SV1)" 4/etc/nginx/conf.d/*/etc/nginx/sites-enabled/*192.168.8.1:3128 weight=5192.168.8.2:80 weight=1192.168.8.3:80 weight=680/www.xx.com.access.log main;//root; # defines the default web site root location of the server / $fastcgi_script_name Include / etc/nginx/fastcgi_params;500 502 503 504 / 50x.htl; location = / 50x.html {root / root;~ ^ / (p_w_picpaths | javascript | js | css | flash | media | static) / / var/www/virtual/~/root; fastcgi_pass 127.0.1HomeNginxStatus {"NginxStatus" / htpasswd;~ /\ ht {168.880192.168.8~. * / root # define the default Web site root location of the server-Forwarded--Real--Forwarded-9090904*2
[IV. Nginx reverse proxy]
Two projects start locally, and the source code is here.
Run under these two folders respectively
Npm installnode server.js
Enter in the browser
Native ip:4789
Native ip:5789
You can access these two pages
And then we want to use
Test.nginx.com accesses page 5789
Test.nginx.com/bug accesses page 5789
Then we first need to configure hosts
The address of hosts under win is C:\ Windows\ System32\ drivers\ etc
We need to add the following configuration to the hosts file
172.18.144.23 test.nginx.com
Then add a server to the http module of nginx
Server {listen 80; server_name test.nginx.com; location / {proxy_pass http://172.18.144.23:4789/;} location / buy {proxy_pass http://172.18.144.23:5789/;} error_page 500502 503 504 / 50x.html Location = / 50x.html {root html;}}
Then restart nginx
Enter test.nginx.com in the browser
Enter test.nginx.com/bug in the browser
Reverse proxy is like this.
[v. Nginx load balancing]
Configure http in nginx
First configure the service of load balancer
Add the following configuration to the http module
Upstream webservers {server 172.18.144.23:4789 weight=10; server 172.18.144.23:5789 weight=10;}
Change server to
Server {listen 80; server_name test.nginx.com; location / {proxy_pass http://webservers;} location / buy {proxy_pass http://172.18.144.23:5789/;} error_page 500502 503 504 / 50x.html Location = / 50x.html {root html;}}
Type test.nginx.com in the browser, refresh, and we can see two pages, indicating that nginx has distributed our request to different places.
After reading the above about the reasons for using Nginx, reverse proxy and load balancing configuration process, if there is anything else you need to know, you can find out what you are interested in in the industry information or find our professional and technical engineers for answers. Technical engineers have more than ten years of experience in the industry.
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: 209
*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.