Category: Nginx

Nginx Rewrite for Special Characters

Original URL:
borrowinfo.page?borrow_id=2017121500000000000000005173
Target URL:
/invest/info?borrowId=2017121500000000000000005173

if ($request_uri ~* "^/borrowinfo.page/?borrow_id=(/d+)$") {

How to Start and Stop Nginx on Windows

Starting:

Navigate to the nginx directory and either double-click nginx.exe in the Nginx folder or run in cmd:
start nginx

Stopping
nginx -s stop
or
nginx -s quit
stop means to immediately stop nginx without saving related information

quit means to exit nginx normally, and …

Nginx proxy_pass URL With or Without Trailing Slash

How to Use Trailing Slashes in Nginx proxy_pass Correctly

When configuring proxy_pass in Nginx, adding a trailing slash (/) to the URL means it is treated as an absolute root path. In this case, Nginx will not forward the matched location path to the proxied server. Without the trailing slash, the matched path segment is also forwarded.

Test file is test.html, access http: …

How to Set Custom Nginx Variables for Logging

Note: This file is the nginx configuration file nginx.conf. Settings here take effect globally. Please define the relevant variable names in your program in advance, and enable the access.log writing feature in nginx (enabled by default). 1. Enable underscore support (by default, underscores in variables are not recognized): vi /usr/local/nginx/conf/ngin …

How to Change TLS Version in Nginx

Recently while working on a WeChat Mini Program, I ran into an issue: the TLS version must be greater than 1.2
Here’s how to fix it:

It’s common knowledge that WeChat Mini Programs only support HTTPS, so I won’t go into SSL configuration here. Below, using my Nginx setup as an example, I’ll show you how to resolve the TLS version requirement: vi /usr/local/nginx/conf/vhost/www. …

How to Configure Nginx User Authentication

Note: The goal is to require visitors to enter a username and password before accessing the site.
The ngx_http_auth_basic_module allows access to web content only when the correct username and password are entered. Some content on the web is not meant for public viewing, but you still want to share it with a select group …