Nginx : Add Basic Doc
This commit is contained in:
63
Nginx/1-Information.md
Normal file
63
Nginx/1-Information.md
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
# Nginx Documentation
|
||||||
|
|
||||||
|
## What Is Nginx?
|
||||||
|
|
||||||
|
**Nginx** (pronounced "engine-x") is a popular open-source web server and reverse proxy software. Known for its high performance, stability, rich feature set, simple configuration, and low resource consumption, Nginx has become one of the most widely used server applications worldwide.
|
||||||
|
|
||||||
|
Originally developed by Igor Sysoev, Nginx was designed to address the **C10k problem**—the challenge of handling 10,000 concurrent client connections. Nginx overcomes this limitation through an **event-driven, asynchronous architecture** that enables it to manage a vast number of simultaneous connections efficiently and with minimal resource usage.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Key Features of Nginx
|
||||||
|
|
||||||
|
1. **High Performance**: Nginx is optimized to handle high-traffic websites and can serve static content faster than many other web servers.
|
||||||
|
|
||||||
|
2. **Stability**: Its design enables stable operation under heavy load, making it reliable for production environments.
|
||||||
|
|
||||||
|
3. **Low Resource Consumption**: The asynchronous architecture minimizes memory and CPU usage, making it suitable for high-concurrency environments.
|
||||||
|
|
||||||
|
4. **Flexibility**: Nginx can be easily configured to function as a web server, reverse proxy, load balancer, and more.
|
||||||
|
|
||||||
|
5. **Security**: Nginx supports SSL/TLS and can be configured for secure HTTPS connections, with built-in features to prevent DoS and DDoS attacks.
|
||||||
|
|
||||||
|
6. **Extensibility**: Through a range of modules, Nginx can be extended to support various functions such as caching, load balancing, access control, and more.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Common Uses of Nginx
|
||||||
|
|
||||||
|
Nginx’s versatility makes it a powerful tool for a wide range of applications. Below are some of its most common uses:
|
||||||
|
|
||||||
|
### 1. Web Server
|
||||||
|
Nginx can serve as a **standalone web server** to deliver static content like HTML files, images, videos, and more. Due to its efficiency, it’s commonly used to serve content directly or in front of other server applications for added performance and caching benefits.
|
||||||
|
|
||||||
|
### 2. Reverse Proxy
|
||||||
|
Acting as a **reverse proxy**, Nginx can forward client requests to another server, often used to route traffic to applications hosted on multiple servers. This approach helps manage and distribute incoming traffic, improving performance and security by hiding the backend server details from clients.
|
||||||
|
|
||||||
|
### 3. Load Balancer
|
||||||
|
Nginx’s **load balancing** capabilities help distribute traffic across multiple servers. Load balancing not only increases fault tolerance by rerouting traffic in case of server failure but also enhances performance by preventing any single server from becoming overloaded.
|
||||||
|
|
||||||
|
Common load balancing methods in Nginx:
|
||||||
|
- **Round Robin**: Distributes requests sequentially across servers.
|
||||||
|
- **Least Connections**: Routes traffic to the server with the fewest active connections.
|
||||||
|
- **IP Hash**: Ensures clients are consistently routed to the same server based on their IP address.
|
||||||
|
|
||||||
|
### 4. Caching
|
||||||
|
Nginx can act as a **caching server** to store copies of frequently requested content. By serving cached content, Nginx can significantly reduce load times for users and lessen the workload on backend servers. This is especially beneficial for high-traffic websites with dynamic content.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Additional Nginx Features
|
||||||
|
|
||||||
|
- **SSL/TLS Termination**: Nginx can terminate SSL/TLS connections, handling the encryption and decryption process to reduce the burden on backend servers.
|
||||||
|
|
||||||
|
- **URL Rewriting and Redirection**: With URL rewriting rules, Nginx can redirect requests to different URLs, enabling efficient handling of routing and user-friendly URLs.
|
||||||
|
|
||||||
|
- **Access Control**: Provides robust tools for managing access controls, including IP-based access restrictions, user authentication, and authorization.
|
||||||
|
|
||||||
|
- **HTTP/2 and HTTP/3 Support**: Supports newer HTTP protocols for faster and more secure connections.
|
||||||
|
|
||||||
|
- **Customizable Modules**: Nginx’s modular architecture allows for custom modules, enabling functionality for a wide range of applications and configurations.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
114
Nginx/2-Installtion.md
Normal file
114
Nginx/2-Installtion.md
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
# Installing Nginx
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
Before installing Nginx, ensure that you have root or sudo privileges on your system to carry out installation and configuration commands.
|
||||||
|
|
||||||
|
## Step-by-Step Installation
|
||||||
|
|
||||||
|
### For Debian-Based Systems (e.g., Ubuntu)
|
||||||
|
|
||||||
|
1. **Update Package Repositories**
|
||||||
|
It’s a good practice to update your package repositories before installing new software to ensure you’re downloading the latest version available.
|
||||||
|
```bash
|
||||||
|
sudo apt update
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **Install Nginx**
|
||||||
|
Install Nginx from the package repository.
|
||||||
|
```bash
|
||||||
|
sudo apt install nginx
|
||||||
|
```
|
||||||
|
|
||||||
|
3. **Start Nginx Service**
|
||||||
|
Once installed, start the Nginx service.
|
||||||
|
```bash
|
||||||
|
sudo systemctl start nginx
|
||||||
|
```
|
||||||
|
|
||||||
|
4. **Enable Nginx to Start on Boot**
|
||||||
|
This command configures Nginx to start automatically whenever the server reboots.
|
||||||
|
```bash
|
||||||
|
sudo systemctl enable nginx
|
||||||
|
```
|
||||||
|
|
||||||
|
5. **Check Status (Optional)**
|
||||||
|
Verify that Nginx is running correctly.
|
||||||
|
```bash
|
||||||
|
sudo systemctl status nginx
|
||||||
|
```
|
||||||
|
|
||||||
|
### For Red Hat-Based Systems (e.g., CentOS, Fedora)
|
||||||
|
|
||||||
|
1. **Update Package Repositories**
|
||||||
|
As with Debian-based systems, it’s recommended to update repositories first.
|
||||||
|
```bash
|
||||||
|
sudo yum update
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **Install Nginx**
|
||||||
|
On Red Hat-based systems, install Nginx with `yum`.
|
||||||
|
```bash
|
||||||
|
sudo yum install nginx
|
||||||
|
```
|
||||||
|
|
||||||
|
3. **Start Nginx Service**
|
||||||
|
Start Nginx after installation.
|
||||||
|
```bash
|
||||||
|
sudo systemctl start nginx
|
||||||
|
```
|
||||||
|
|
||||||
|
4. **Enable Nginx to Start on Boot**
|
||||||
|
Configure Nginx to launch automatically on system startup.
|
||||||
|
```bash
|
||||||
|
sudo systemctl enable nginx
|
||||||
|
```
|
||||||
|
|
||||||
|
5. **Check Status (Optional)**
|
||||||
|
Confirm that Nginx is running and functioning properly.
|
||||||
|
```bash
|
||||||
|
sudo systemctl status nginx
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Post-Installation Steps
|
||||||
|
|
||||||
|
1. **Allow Nginx Through the Firewall**
|
||||||
|
If your server has a firewall enabled, you may need to allow HTTP (port 80) and HTTPS (port 443) traffic.
|
||||||
|
|
||||||
|
### Debian-Based Systems:
|
||||||
|
```bash
|
||||||
|
sudo ufw allow 'Nginx Full'
|
||||||
|
```
|
||||||
|
|
||||||
|
### Red Hat-Based Systems:
|
||||||
|
```bash
|
||||||
|
sudo firewall-cmd --permanent --add-service=http
|
||||||
|
sudo firewall-cmd --permanent --add-service=https
|
||||||
|
sudo firewall-cmd --reload
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **Verify Installation**
|
||||||
|
Open a web browser and navigate to your server’s IP address or domain name:
|
||||||
|
```
|
||||||
|
http://<your-server-ip>
|
||||||
|
```
|
||||||
|
You should see the default Nginx welcome page, which confirms that the installation is successful.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Troubleshooting Common Installation Issues
|
||||||
|
|
||||||
|
- **Error: Package Not Found**
|
||||||
|
If you encounter an error stating that the Nginx package was not found, you may need to install the **EPEL repository** (Extra Packages for Enterprise Linux) on Red Hat-based systems:
|
||||||
|
```bash
|
||||||
|
sudo yum install epel-release
|
||||||
|
sudo yum install nginx
|
||||||
|
```
|
||||||
|
|
||||||
|
- **Permission Denied Errors**
|
||||||
|
Ensure you’re using `sudo` to run commands that require root privileges.
|
||||||
|
|
||||||
|
- **Firewall Blocking Access**
|
||||||
|
If you can’t access Nginx via a browser, ensure that firewall rules are configured to allow HTTP/HTTPS traffic.
|
||||||
|
|
||||||
Reference in New Issue
Block a user