BlogWeb
-
6 min readTo change the client_max_body_size of Nginx in Docker, you can follow these steps:Locate the Nginx configuration file: In your Docker container, the Nginx configuration file is usually located at /etc/nginx/nginx.conf. This file contains all the server configurations. Edit the Nginx configuration file: Open the configuration file using a text editor (e.g., vi, nano, etc.). Look for the http block, which contains various server configurations.
-
11 min readTo strip unwanted parameters from a URL using nginx, you can use the $args variable in combination with the rewrite directive. Here is how you can do it:Open your nginx configuration file using a text editor. This file is usually located at /etc/nginx/nginx.conf. Within the server block or a specific location block, add the following rewrite directive: location / { ... rewrite ^([^?]*)(?:\?(?!key=)[^&]+)*$ $1 permanent; ...
-
7 min read$connection_time is a variable in Nginx that represents the total time it took to establish a connection with a client. It measures the duration from when the connection process begins until it is completed or terminated. This variable is commonly used in log files and for monitoring purposes to analyze server performance and identify any potential bottlenecks. By examining $connection_time, administrators can gain insights into network latency, connection quality, and overall system health.
-
6 min readTo change the root path in the nginx configuration, you need to make some adjustments in the server block of the configuration file. Follow the steps below:Open the nginx configuration file using a text editor. The main configuration file is typically located at /etc/nginx/nginx.conf or /etc/nginx/conf.d/default.conf. However, it can vary depending on your system. Locate the relevant server block. In most cases, it starts with server { and ends with }.
-
9 min readTo implement basic rate limiting with NGINX, you can follow these steps:Open your NGINX configuration file (usually located at /etc/nginx/nginx.conf or /etc/nginx/conf.d/default.conf) using a text editor. Inside the http block, add the following code snippet to define a new limit_req_zone: http { ... limit_req_zone $binary_remote_addr zone=mylimit:10m rate=1r/s; ...
-
14 min readTo build a proxy using Nginx, you need to follow these steps:Install Nginx: Start by installing Nginx on your server or local machine. You can download it from the official Nginx website or use package managers like apt or yum. Configure Nginx as a Reverse Proxy: To use Nginx as a proxy server, you need to configure it as a reverse proxy. Open the Nginx configuration file (usually located at /etc/nginx/nginx.conf) in a text editor.
-
11 min readTo restrict access to a site by IP through NGINX, you can follow these steps:Edit the NGINX configuration file for the specific site or default configuration located at /etc/nginx/sites-available/. Within the server block, use the allow and deny directives to define the IP addresses you want to allow or deny access to.
-
9 min readTo override the location directive in Nginx, you can modify the Nginx configuration file (usually located at /etc/nginx/nginx.conf, /etc/nginx/conf.d/*.conf, or /etc/nginx/sites-available/*) or create a new custom configuration file in conf.d or sites-available directory.Open the Nginx configuration file using a text editor: sudo nano /etc/nginx/nginx.conf Locate the server block where you want to override the location directive. Typically, it looks like this: server { ... location / { ... } ...
-
7 min readTo enable the PUT and DELETE methods on Nginx, you need to modify your Nginx configuration file. Follow the steps below:Find and open your Nginx configuration file. This file is usually located at /etc/nginx/nginx.conf, /etc/nginx/sites-enabled/default, or /etc/nginx/conf.d/default.conf. Inside the configuration file, locate the http block. This block typically starts with http { and ends with }.
-
13 min readTo figure out slow requests in Nginx, there are several steps you can follow:Enable Nginx access logs: Open the Nginx configuration file (usually located at /etc/nginx/nginx.conf) and ensure that logging is enabled. Look for the access_log directive and make sure it's uncommented. Define log format: Set a custom log format that includes the variables you need to analyze slow requests. For example, you can include the $request_time variable to measure the time taken for each request.
-
9 min readGetting a real IP on Layer 4 by NGINX involves some configuration settings. Here's how to do it:Open your NGINX configuration file, usually located at /etc/nginx/nginx.conf or /etc/nginx/conf.d/default.conf. Look for the http block and add or modify the following lines: http { ... set_real_ip_from ; # Replace with the actual IP address of your load balancer or proxy server real_ip_header X-Real-IP; real_ip_recursive on; ...