Nginx is a high-performance HTTP and reverse proxy server, as well as an IMAP/POP3/SMTP proxy server. It was created by Igor Sysoev and first released in 2004. Nginx is known for its high concurrency and low resource consumption, and is widely used in web servers and reverse proxy servers.
Main Features of Nginx
High concurrency: Nginx uses an event-driven architecture that can handle a large number of concurrent connections, making it suitable for high-traffic websites.
Low resource consumption: Nginx's design allows it to consume less memory and CPU resources when handling a large number of connections.
Reverse proxy and load balancing: Nginx can act as a reverse proxy server, distributing client requests to backend servers to achieve load balancing.
Static file service: Nginx can efficiently serve static files such as HTML, CSS, JavaScript, images, etc.
Modular design: Nginx supports extending functionality through modules, allowing different modules to be loaded as needed.
Support for multiple protocols: Nginx supports HTTP, HTTPS, IMAP, POP3, and SMTP protocols.
Main Nginx Configuration File
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
Secondary Nginx Configuration File
server {
listen 80;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}