ngnix learning summary

1nginx.conf file

Insert picture description hereInsert picture description here

Mainly modify the server

2 reverse proxy

Reverse proxy, in fact, a client of the agency is not aware of, because the client does not need any configuration you can visit, we only
need to send a request to the reverse proxy server, the reverse proxy server to select the target server to get data, When it is returned
to the client, the reverse proxy server and the target server are external servers, and the
address of the proxy server is exposed , but the real server IP address is hidden.
Insert picture description here

Reverse proxy:
1. The reverse proxy server is configured on the server side.
2. The client does not know which server is being accessed.
3. Load balance is achieved and the real IP address of the server can be hidden.

Insert picture description here

3 About Nginx's location path mapping

Priority relationship:

(location =)> (location /xxx/yyy/zzz)> (location ^~)> (location
, *)> (location /starting path)> (location /)



Insert picture description here
#Visit http://192.168.199.109/index to enter the tomcat homepage
#Visit http://192.168.199.109/ssm to enter the ssm project homepage
#Visit http://192.168.199.109/ to enter Hello Nginx!!

Port 80 is the default network port, no need to add 80 to access

4 load balancing

A single server can not be resolved, we increase the number of servers, then distribute requests to each server, and the original
request for the case to focus on a single server instead distribute requests across multiple servers, the load is distributed to different service
traffic control , Which is what we call load balancing
Insert picture description here
Insert picture description here

4.1 Polling

Insert picture description here
example:

upstream my_server{
    
    
    server ncthz.top:8080;
    server ncthz.top:8081;
}
server {
    
    
    listen       80;
    listen  [::]:80;
    server_name  localhost;//即ncthz.top

	location / {
    
    
        proxy_pass http://my_server/;	#tomcat首页
    }
}

Refresh the ncthz.top page several times, according to the version number we can find that we have entered a different tomcat
Insert picture description here
Insert picture description here

4.2 Weight

4.3 ip_hash

5 Dynamic and static separation

Nginx's concurrency formula:
worker_processes * worker_connections / 4|2 = Nginx's final concurrency.
Dynamic resource requirement/4, static resource requirement/2
Nginx uses dynamic and static separation to improve Nginx's concurrency capacity and respond to users faster (no need Access server, increase speed)

Insert picture description here

Insert picture description here

6 clusters

单点故障,避免nginx的宕机,导致整个程序的崩溃
准备多台Nginx
准备keepalived,监听nginx的健康情况
准备haproxy,提供一个虚拟的路径,统一的去接收用户的请求

Insert picture description here

reference

1
https://blog.csdn.net/m0_49558851/article/details/107786372

2

https://nishigouzi.github.io/2020/06/07/Nginx%E7%AC%94%E8%AE%B0/#more
corresponds to the brain map
https://besterwin.gitee.io/blogs/knowledge/middle /Nginx.html

3
https://www.bookstack.cn/read/dunwu-nginx-tutorial/spilt.6.docs-nginx-configuration.md

Guess you like

Origin blog.csdn.net/Insist___/article/details/109305099