📜  nginx (1)

📅  最后修改于: 2023-12-03 15:33:06.871000             🧑  作者: Mango

Nginx

Nginx Logo

Nginx is a high-performance open-source web server software. It can also act as a reverse proxy, load balancer and HTTP cache. It was created by Igor Sysoev and first released in 2004. Nginx is known for its low resource consumption and ability to handle a large number of concurrent connections.

Features

Some of the features of Nginx are:

  • High performance
  • Low resource consumption
  • Event-based model with asynchronous IO
  • Support for multiple protocols (HTTP, SMTP, IMAP, POP3)
  • Ability to act as a reverse proxy and load balancer
  • HTTP caching and compression
  • SSL and TLS support
  • Access and error logging
  • URL rewriting
  • IPv6 support
  • Lua scripting
  • Dynamic module loading
Installation

Nginx can be installed on several operating systems, including Linux, BSD, macOS and Windows. Here is an example of how to install Nginx on a Ubuntu server:

sudo apt update
sudo apt install nginx
Configuration

Nginx configuration is done using plain text files that are typically located in the /etc/nginx directory. The main configuration file is nginx.conf. Here is an example of a simple Nginx configuration:

worker_processes auto;
events {
    worker_connections 1024;
}
http {
    server {
        listen 80;
        server_name example.com;
        location / {
            root /var/www/html;
            index index.html;
        }
    }
}

This configuration sets the number of worker processes based on the number of CPU cores, allows up to 1024 connections per worker, defines a HTTP server listening on port 80 for the domain example.com, and serves static files from the /var/www/html directory.

Conclusion

Nginx is a powerful and versatile web server that is widely used in the industry. Its low resource consumption, high performance and event-based model make it an attractive choice for serving static content, handling large traffic volumes and acting as a reverse proxy or load balancer.