Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The principle and usage of Nginx

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "the principle and usage of Nginx". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "the principle and usage of Nginx".

Nginx

Load balancing:

When the number of visits to the website reaches a certain extent, when a single server can not meet the requirements of users, it is necessary to use multiple server clusters to ensure the normal operation of the server, and load balancing can make multiple servers share the load equally.

Reverse proxy: browser-> Nginx (reverse proxy)-- > server-- > browser

Advantages: security, cross-domain

Code:

Server {

Listen 80

Server_name 119.23.231.91

Location / {

Proxy_pass http://119.23.231.91:8080;

}

}

Load balancing (cluster):

Advantages:

When a falls down, you can use the b server to share the pressure on the server. if a has been accessed, you can go to the b server to find it, which greatly reduces the pressure on the server.

Code:

# load balancer: down (do not participate), ip_hash (fixed server), weight (priority)

Upstream name {

Server localhost:8081 weight=3

Server localhost:8082 weight=1

Server localhost:8083 weight=1

}

Server {

Listen 80

Server_name localhost

Location / {

Proxy_pass http://name;

}

}

Multiple servers: multiple server servers can be implemented using multiple nginx servers.

Server {

Listen 80

Server_name 119.23.231.91

Location / {

Proxy_pass http://119.23.231.91:8080;

}

}

Server {

Listen 9090

Server_name 119.23.231.99

Location / {

Proxy_pass http://119.23.231.99:8080;

}

}

Command:

Start: C:\ nginx start nginx

End: C:\ nginx nginx-s quit or stop

Overload: C:\ nginx nginx-s reload

There is a problem:

1.session sharing.

two。 Upload and download access to pictures and files

Solution:

1.redis 's session cache or stores the mysql database

two。 Set up a special file server

Thank you for your reading, the above is the content of "the principle and use of Nginx". After the study of this article, I believe you have a deeper understanding of the principle and use of Nginx, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report