current location:Home > Technical Articles > Operation and Maintenance > Nginx

  • How to configure nginx to return text or json
    How to configure nginx to return text or json
    Let's first look at returning fixed text and json. You can configure location interception in the server. The configuration example is as follows: Fixed text: location~^/get_text{default_typetext/html;return200'thisitext!';} Fixed json:location~^ /get_json{default_typeapplication/json;return200'{"status":"success",&q
    Nginx 2224 2023-05-18 13:19:14
  • How to configure location and rewrite rules in Nginx
    How to configure location and rewrite rules in Nginx
    Location tutorial example: location=/{#Exact match/, the host name cannot be followed by any string [configurationA]}location/{#Because all addresses begin with /, this rule will match all requests#But regular and the longest string will be matched first [configurationB]}location/documents/{#Match any address starting with /documents/. After matching, continue to search downwards#Only when the subsequent regular expression is not matched, This article will use [configurationC]}location~/document
    Nginx 1574 2023-05-18 12:25:06
  • How to implement Nginx current limiting
    How to implement Nginx current limiting
    How does nginx current limiting work? Nginx current limiting uses the leaky bucket algorithm (leakybucket algorithm), which is widely used in communications and packet switching-based computer networks to handle emergencies when bandwidth is limited. The principle is very similar to a bucket with water entering from above and leaking from below; if the rate of water inflow is greater than the rate of water leakage, the bucket will overflow. In the request processing process, the water represents the request from the client, and the bucket represents a queue in which the request is waiting to be processed according to the first-in-first-out (fifo) algorithm. A leak means a request leaves the buffer and is processed by the server, an overflow means a request is dropped and never served. 1. Limit access frequency (normal traffic) ngi
    Nginx 2089 2023-05-18 12:07:35
  • How to intercept uri in nginx location
    How to intercept uri in nginx location
    Note: The root and aliasroot instructions in location only set the search root to the directory set by root, that is, the uri will not be truncated. Instead, the original uri will be used to jump to the directory to find the file. The aias instruction will truncate the matching uri, and then Use the path set by alias plus the remaining uri as a sub-path to find the uri of proxy_pass in location. If the url of proxy_pass does not have uri, if the tail is "/", the matching uri will be truncated. If the tail is not "/", then Will not truncate the matching uri if the proxy_pass url contains uri
    Nginx 1568 2023-05-18 12:07:06
  • How to configure basic memory pool initialization in Nginx
    How to configure basic memory pool initialization in Nginx
    Initialization of ngx_cycle During the entire initialization process, the most important thing is the initialization of the global variable nginx_cycle. Many variables are initialized during this process. nginx_cycle is initialized through two local variables init_cycle and cycle. In fact, log initialization can also be regarded as Initialization of nginx_cyle, because what happens next in the code is an assignment ngx_memzero(&init_cycle,sizeof(ngx_cycle_t));init_cycle.log=log;ngx_cycle=&init_cycl
    Nginx 711 2023-05-18 12:01:06
  • How to configure nginx server multi-site
    How to configure nginx server multi-site
    1. First, find the location of the nginx configuration file. The nginx.conf file on Alibaba Cloud is in /alidata/server/nginx-1.4.4/conf. 2. Then create a vhosts directory in the conf directory. This directory is used to store the configuration files of different sites. 3. Then, add a line include/alidata/server/nginx/conf/vhosts/*.conf;userwwwwww;worker_processes1;error_log/alidata/log/nginx/error at the end of nginx.conf
    Nginx 2524 2023-05-18 11:29:01
  • How to solve 403 caused by Nginx website root directory change
    How to solve 403 caused by Nginx website root directory change
    1. Change the root directory. The default website root directory of nginx is /usr/local/nginx/html. To change it to /home/fuxiao/www, change the method: vi/usr/local/nginx/conf/nginx.conf. Change location/{roothtml;indexindex.phpindex.htmlindex.htm;} to location/{root/home/fuxiao/www;indexindex.phpindex.htmlindex.htm;} and then change location~\.php${ro
    Nginx 1068 2023-05-18 10:28:12
  • How to configure Nginx to divert traffic based on the last segment of the request IP
    How to configure Nginx to divert traffic based on the last segment of the request IP
    Mainly the configuration jump of the if judgment in the location parameter, offloading can reduce the load and pressure of the server. This is a very common server deployment architecture. Jump according to the range of the last segment of ip #Please modify the domain name, ip, port and other information yourself upstreamhuaji-01.com{server192.168.1.100:8080;}upstreamhuaji-02.com{server192.168.1.200:8080;} server{listen80;server_namewww.huaji.com;location/{if($remote_addr~
    Nginx 1155 2023-05-18 10:10:34
  • How to customize exclusive 404 page in Nginx
    How to customize exclusive 404 page in Nginx
    The first: Nginx's own error page Nginx accesses a static html page. When this page does not exist, Nginx throws 404. So how to return 404 to the client? Look at the configuration below. In this case, there is no need to modify any parameters to achieve this function. server{listen80;server_namewww.test.com;root/var/www/test;indexindex.htmlindex.htm;location/{}#Define the error page code. If the corresponding error page code appears, forward it there. error_page404403500502503
    Nginx 1806 2023-05-18 09:04:13
  • How to configure and use proxy protocol in nginx
    How to configure and use proxy protocol in nginx
    When proxyprotocol is used in nginx, we know that nginx is a web server and proxy server. It generally works behind proxyserver or load balancing software (Haproxy, Amazon Elastic LoadBalancer (ELB)). The client first requests proxyserver or LSB load balancing software, and then to nginx Perform real web access. Because it has gone through multiple layers of software, some client information such as IP address, port number, etc. may be hidden, which is detrimental to our problem analysis and data statistics. Because for nginx, We want to be able to get real clients
    Nginx 2739 2023-05-18 08:47:26
  • How to solve the problems encountered when installing vsftpd in nginx
    How to solve the problems encountered when installing vsftpd in nginx
    The simplest installation steps [root@itdragon~]#useraddftpuser[root@itdragon~]#passwdftpuserchangingpasswordforuserftpuser.newpassword:badpassword:itistooshortbadpassword:istoosimpleretypenewpassword:passwd:allauthenticationtokensupdatedsuccessfully.[root@itdragon~]#yum-yi
    Nginx 653 2023-05-18 08:40:05
  • How to use Nginx to deal with cross-domain issues in the Vue development environment
    How to use Nginx to deal with cross-domain issues in the Vue development environment
    1. The local test domain name needs to be the same as the online domain name in order to correctly deliver cookies and perform SSO testing. Note: Since the relevant cookies are added to the fourth-level domain name after sso login, the local test domain name and the online interface domain name need to be the same. 2. The plan is to configure the host file so that the online domain name points to localhost: 127.0.0.1product.xxx.xxx.com and configure nginx for corresponding forwarding: server{listen80;listen[::]:80;server_name${product.xxx.xxx. com};location/api{proxy_passhtt
    Nginx 1617 2023-05-18 08:28:05
  • How to configure Nginx to prohibit access to a certain directory or file
    How to configure Nginx to prohibit access to a certain directory or file
    Copy the code as follows: location=/config/{return404;} location=/config.ini{return404;} This will only prohibit access to //www.jb51.net/path/ Copy the code as follows: location=/path/{ return404;} Access to //www.jb51.net/path/test.php is prohibited. Copy the code as follows: location^~/test{denyall;} Maybe test should be replaced with path.
    Nginx 2845 2023-05-18 08:04:15
  • Nginx installation and configuration example analysis
    Nginx installation and configuration example analysis
    nginx is a free, open source, high-performance http server and reverse proxy server; it is also an imap, pop3, and smtp proxy server; nginx can be used as an http server for website publishing and processing, and nginx can be used as a reverse proxy server. The proxy implements load balancing. Here we briefly introduce nginx reverse proxy load balancing nginx features from three aspects: 1. Reverse proxy About proxy Speaking of proxy, first we have to clarify a concept, the so-called proxy is a representative and a channel; at this time, we design two Roles, one is the agent role and the other is the target role. The process in which the agent role accesses the target role to complete some tasks through this agent is called agency.
    Nginx 738 2023-05-17 23:28:04
  • How to set WordPress pseudo-static in Nginx
    How to set WordPress pseudo-static in Nginx
    First, configure the server module in nginx as follows: location/{if(-f$request_filename/index.html){rewrite(.*)$1/index.htmlbreak;}if(-f$request_filename/index.php) {rewrite(.*)$1/index.php;}if(!-f$request_filename){rewrite(.*)/index.php;}}After the configuration is completed, restart nginx and then go to the "Settings" in the WordPress blog background --"fixed
    Nginx 2118 2023-05-17 23:25:04

Tool Recommendations

jQuery enterprise message form contact code

jQuery enterprise message form contact code is a simple and practical enterprise message form and contact us introduction page code.
form button
2024-02-29

HTML5 MP3 music box playback effects

HTML5 MP3 music box playback special effect is an mp3 music player based on HTML5 css3 to create cute music box emoticons and click the switch button.

HTML5 cool particle animation navigation menu special effects

HTML5 cool particle animation navigation menu special effect is a special effect that changes color when the navigation menu is hovered by the mouse.
Menu navigation
2024-02-29

jQuery visual form drag and drop editing code

jQuery visual form drag and drop editing code is a visual form based on jQuery and bootstrap framework.
form button
2024-02-29

Organic fruit and vegetable supplier web template Bootstrap5

An organic fruit and vegetable supplier web template-Bootstrap5
Bootstrap template
2023-02-03

Bootstrap3 multifunctional data information background management responsive web page template-Novus

Bootstrap3 multifunctional data information background management responsive web page template-Novus
backend template
2023-02-02

Real estate resource service platform web page template Bootstrap5

Real estate resource service platform web page template Bootstrap5
Bootstrap template
2023-02-02

Simple resume information web template Bootstrap4

Simple resume information web template Bootstrap4
Bootstrap template
2023-02-02

Cute summer elements vector material (EPS PNG)

This is a cute summer element vector material, including the sun, sun hat, coconut tree, bikini, airplane, watermelon, ice cream, ice cream, cold drink, swimming ring, flip-flops, pineapple, conch, shell, starfish, crab, Lemons, sunscreen, sunglasses, etc., the materials are provided in EPS and PNG formats, including JPG previews.
PNG material
2024-05-09

Four red 2023 graduation badges vector material (AI EPS PNG)

This is a red 2023 graduation badge vector material, four in total, available in AI, EPS and PNG formats, including JPG preview.
PNG material
2024-02-29

Singing bird and cart filled with flowers design spring banner vector material (AI EPS)

This is a spring banner vector material designed with singing birds and a cart full of flowers. It is available in AI and EPS formats, including JPG preview.
banner picture
2024-02-29

Golden graduation cap vector material (EPS PNG)

This is a golden graduation cap vector material, available in EPS and PNG formats, including JPG preview.
PNG material
2024-02-27

Home Decor Cleaning and Repair Service Company Website Template

Home Decoration Cleaning and Maintenance Service Company Website Template is a website template download suitable for promotional websites that provide home decoration, cleaning, maintenance and other service organizations. Tip: This template calls the Google font library, and the page may open slowly.
Front-end template
2024-05-09

Fresh color personal resume guide page template

Fresh color matching personal job application resume guide page template is a personal job search resume work display guide page web template download suitable for fresh color matching style. Tip: This template calls the Google font library, and the page may open slowly.
Front-end template
2024-02-29

Designer Creative Job Resume Web Template

Designer Creative Job Resume Web Template is a downloadable web template for personal job resume display suitable for various designer positions. Tip: This template calls the Google font library, and the page may open slowly.
Front-end template
2024-02-28

Modern engineering construction company website template

The modern engineering and construction company website template is a downloadable website template suitable for promotion of the engineering and construction service industry. Tip: This template calls the Google font library, and the page may open slowly.
Front-end template
2024-02-28
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!