search

What nginx mainly does

Aug 08, 2019 am 09:22 AM
nginx

What nginx mainly does

What does nginx mainly do?

Nginx is a high-performance HTTP and reverse proxy service, as well as an IMAP/POP3/SMTP service. Nginx was developed by the Russians.

Nginx is a lightweight web server/reverse proxy server and email (IMAP/POP3) proxy server, and is released under a BSD-like protocol. Its characteristics are that it occupies less memory and has strong concurrency capabilities. In fact, nginx’s concurrency capabilities do perform better among web servers of the same type. Most websites in mainland China use nginx.

1.1: Generally, websites using Nginx will mainly use

1. Reverse proxy

2. Load balancing

3. HTTP server (including dynamic Separation)

1.2 Reverse proxy

What nginx mainly does

A picture tells you that it is not very clear and not easy to understand. Simply put, it is accepted by the proxy server. The connection request on the Internet is then forwarded to the server on the internal network, and the results obtained from the server are returned to the client requesting the connection on the Internet. At this time, the proxy server appears as a reverse proxy server to the outside world.

1.3 Load Balancing

What nginx mainly does

The diagram can tell you simply, and then the algorithm used can also be shared with everyone

Polling (default): Each request is assigned to different back-end servers one by one in chronological order. If a back-end server goes down, the faulty machine will be automatically removed so that user access is not affected. I personally think this is the best , but there is also a cost, which is the cost of the machine! The actual situation has also verified this, the token of the mobile segment!

weight:

Specify the polling weight. The larger the weight value, the higher the probability of allocation. It is mainly used when the performance of each server in the backend is unbalanced. Personally, I don’t think this is necessary. Nowadays, the servers of most enterprises are on the cloud, and the configurations between machines are not much different. It doesn’t require a full-time job, and it’s not necessary!

ip_hash:

Each request is allocated according to the hash result of the access IP, so that each visitor has fixed access to a back-end server, which can effectively solve the session sharing problem of dynamic web pages. This is a common approach adopted in the PC era to solve the problem of session. As technology slowly evolves, session is no longer shared by netizens, and what follows is token, which solves the problem of user permission verification. This can only be used on small websites. The worst thing is that the access and traffic are all on a tomcat, so this approach is unlikely to be adopted!

1.3 HTTP server (including dynamic and static separation)

Nginx itself is also a static resource server. When there are only static resources, you can use Nginx as the server. At the same time, static resources are also very popular now. Separation can be achieved through Nginx. First, let's look at Nginx as a static resource server and separate some static resources. Each service does not need to be pulled from the network, and it is the fastest in terms of data.

1.4 Summary

Nginx has slowly acquired the heavyweight apache with light weight. It is now the mainstream, but it has been slowly replaced by others in recent years. Live until you are old, learn from the old, and embrace it. Variety!

The above is the detailed content of What nginx mainly does. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
NGINX's Purpose: Serving Web Content and MoreNGINX's Purpose: Serving Web Content and MoreMay 08, 2025 am 12:07 AM

NGINXserveswebcontentandactsasareverseproxy,loadbalancer,andmore.1)ItefficientlyservesstaticcontentlikeHTMLandimages.2)Itfunctionsasareverseproxyandloadbalancer,distributingtrafficacrossservers.3)NGINXenhancesperformancethroughcaching.4)Itofferssecur

NGINX Unit: Streamlining Application DeploymentNGINX Unit: Streamlining Application DeploymentMay 07, 2025 am 12:08 AM

NGINXUnit simplifies application deployment with dynamic configuration and multilingual support. 1) Dynamic configuration can be modified without restarting the server. 2) Supports multiple programming languages, such as Python, PHP, and Java. 3) Adopt asynchronous non-blocking I/O model to improve high concurrency processing performance.

NGINX's Impact: Web Servers and BeyondNGINX's Impact: Web Servers and BeyondMay 06, 2025 am 12:05 AM

NGINX initially solved the C10K problem and has now developed into an all-rounder who handles load balancing, reverse proxying and API gateways. 1) It is well-known for event-driven and non-blocking architectures and is suitable for high concurrency. 2) NGINX can be used as an HTTP and reverse proxy server, supporting IMAP/POP3. 3) Its working principle is based on event-driven and asynchronous I/O models, improving performance. 4) Basic usage includes configuring virtual hosts and load balancing, and advanced usage involves complex load balancing and caching strategies. 5) Common errors include configuration syntax errors and permission issues, and debugging skills include using nginx-t command and stub_status module. 6) Performance optimization suggestions include adjusting worker parameters, using gzip compression and

Nginx Troubleshooting: Diagnosing and Resolving Common ErrorsNginx Troubleshooting: Diagnosing and Resolving Common ErrorsMay 05, 2025 am 12:09 AM

Diagnosis and solutions for common errors of Nginx include: 1. View log files, 2. Adjust configuration files, 3. Optimize performance. By analyzing logs, adjusting timeout settings and optimizing cache and load balancing, errors such as 404, 502, 504 can be effectively resolved to improve website stability and performance.

Deploying Applications with NGINX Unit: A GuideDeploying Applications with NGINX Unit: A GuideMay 04, 2025 am 12:03 AM

NGINXUnitischosenfordeployingapplicationsduetoitsflexibility,easeofuse,andabilitytohandledynamicapplications.1)ItsupportsmultipleprogramminglanguageslikePython,PHP,Node.js,andJava.2)Itallowsdynamicreconfigurationwithoutdowntime.3)ItusesJSONforconfigu

NGINX and Web Hosting: Serving Files and Managing TrafficNGINX and Web Hosting: Serving Files and Managing TrafficMay 03, 2025 am 12:14 AM

NGINX can be used to serve files and manage traffic. 1) Configure NGINX service static files: define the listening port and file directory. 2) Implement load balancing and traffic management: Use upstream module and cache policies to optimize performance.

NGINX vs. Apache: Comparing Web Server TechnologiesNGINX vs. Apache: Comparing Web Server TechnologiesMay 02, 2025 am 12:08 AM

NGINX is suitable for handling high concurrency and static content, while Apache is suitable for dynamic content and complex URL rewrites. 1.NGINX adopts an event-driven model, suitable for high concurrency. 2. Apache uses process or thread model, which is suitable for dynamic content. 3. NGINX configuration is simple, Apache configuration is complex but more flexible.

NGINX and Apache: Deployment and ConfigurationNGINX and Apache: Deployment and ConfigurationMay 01, 2025 am 12:08 AM

NGINX and Apache each have their own advantages, and the choice depends on the specific needs. 1.NGINX is suitable for high concurrency, with simple deployment, and configuration examples include virtual hosts and reverse proxy. 2. Apache is suitable for complex configurations and is equally simple to deploy. Configuration examples include virtual hosts and URL rewrites.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.