Category: Nginx

A Case Study of Nginx 499 Errors on POST Requests Caused by Redis Whitelist

A couple of days ago, I added a new server to the website, using Alibaba Cloud for Redis, the server itself, MySQL, and so on. After adding it and enabling load balancing, the Nginx logs showed a large number of 499 status errors, all of which were POST requests. The new server environment was identical to the original server, and the original server was working normally. Following online tutorials, I added to the configuration file …

Compiling and Installing OpenResty

Here we use openresty-1.19.9.1 as an example. yum -y install epel-release perl pcre-devel openssl-devel gcc curl unzip wget zip useradd www cd /home && wget https://mirror.cnop.net/web/openresty/openresty-1.19 …

How to Install the GeoIP2 Module for Tengine/Nginx

How to Install the Nginx GeoIP2 Module to Block IPs by Country and City

The GeoIP module for Nginx allows you to block IP addresses by country or city, which is essential for website security. However, it requires manual compilation and installation.
Step 1: Install the GeoIP2 Extension Dependency
yum install libmaxminddb-devel -y
# This library is required for installing ngx_http_geoi …

Nginx CPU Core Optimization

4-core configuration:
worker_processes 4;
worker_cpu_affinity 0001 0010 0100 1000

8-core configuration:
worker_processes 8;
worker_cpu_affinity 00000001 00000010 00000100 0000100000010000 00100000 01000000 10000000;

Explanation …

Nginx CORS Solution

Example below, adjust as needed:
server
{
listen 80 ;
server_name api.xxx.com;
index index.html index.php;
root /www/admin/public;
add_header …

How to Restrict Access by Country Using Nginx GeoIP Module

This article describes how to use the GeoIP module to enable Nginx to restrict access by users from specific regions. Nginx must be compiled with the –with-http_geoip_module parameter.

1. First, check whether Nginx has been compiled with the GeoIP module nginx -V if you see – …