â–Œproxy_intercept_errors

When the upstream server's response header comes back, it can intercept error processing according to the value of the response status code, and combine it with the error_page instruction. Used when there is an error in accessing the upstream server.

What is the relationship between error_page and proxy instructions

Service deployment

1. Main service (nginx:80), /usr/local/nginx/sbin/nginx

2. Upstream service (nginx:8012), /usr/local/nginx_8012/nginx

Upstream server file description

What is the relationship between error_page and proxy instructions

404.html and 404_default.html content:

What is the relationship between error_page and proxy instructions

04.html: The content of a specific 404 page provided by the upstream server. When nginx:80 accesses the upstream server resource does not exist (404 is returned), the content page is required to be displayed. 404_default.html: The default 404 page of the upstream server. 50x.html: The content of a specific 50x page provided by the upstream server. When nginx:80 accesses the upstream server, a 50x error (including 500, 502, 503 and 504) occurs and the content page is required to be displayed. 50x_default.html: The default page that handles 50x provided by the upstream server

note:

404.html and 50x.html are used in the nginx:80 configuration

404_default.html and 50x_default.html are used in nginx:8012 configuration

Configuration of 404 and 50x in nginx:80 service

What is the relationship between error_page and proxy instructions

Nginx: configuration of 404 and 50x in 8012 service

What is the relationship between error_page and proxy instructions

Several configurations

1. Specific location configuration of nginx:80 service

1). Enable proxy_intercept_errors 2). Set specific error_page to handle 404 and 50x respectively

The configuration is as follows

What is the relationship between error_page and proxy instructions

See @404fallback and @50xfallback configuration

Request a test:

When a non-existent upstream resource is requested through the nginx:80 service, the response result is as follows:

What is the relationship between error_page and proxy instructions

The results are explained:

1. Due to the configuration of the upstream server

add_header Cache-Control max-age=5;

add_header Content-Encoding gzip;

So the response header contains Cache-Control and gzip headers.

2. Due to the nginx:80 configuration, when a 404 appears, the specific content must be obtained from the upstream server.

@404fallback configuration

So the content of the response is:

Upstream server provides a special page for representing 404.

2. The above configuration remains unchanged, modify the resource name in @404fallback

(Modified from 404.html to 404_not_exists.html)

What is the relationship between error_page and proxy instructions

This resource does not exist in the file list of the upstream server

When executing the request test, the results are as follows:

What is the relationship between error_page and proxy instructions

Explain the results:

1. Because the requested nginx:8012 server /404_not_exists.html does not exist, the location / {xxx} configuration in nginx:8012 is not matched (see Figure 1-3). So the response header does not add Cache-Control and gzip.

2. Go to the 404 processing flow of nginx:8012, so the response content is as follows, which is the content of 404_default.html.

Upstream default 404 page.

Three, test different positions of error_page

1). Turn off the error_page instruction in nginx:80 location

2). Set the error_page directive at the server level for nginx:80, set 404 and 50x respectively

What is the relationship between error_page and proxy instructions

The test result is the same as one

What is the relationship between error_page and proxy instructions

Note that there is no test to modify the situation where the resources inside @fallback do not exist. Follow-up supplement

Four, other function descriptions about error_page

1. Modify error_page as:

What is the relationship between error_page and proxy instructions

The test results are:

Explanation of results:

a. This way of writing can modify the status code of the response header. That is, you can modify 404 or other 5xx status codes to 200. Do not fill in the default value is 200

b. Note: There is a space between the equal sign and @404fallback

c. The above configuration is the same as changing error_page to error_page 404 =200 @404fallback;

2. Modify the response status code to the specified value. Such as 301, 302, etc.

What is the relationship between error_page and proxy instructions

Test Results:

What is the relationship between error_page and proxy instructions

to sum up

1. You can turn on proxy_intercept_errors in a specific location to handle the specific response status code of the upstream server. And get the content of the custom error page, and display the content without changing the url requested by the user.

2. The response status code can be changed in combination with error_page.

Electric Slip Ring

An electric slip ring is a rotary electrical connector. It allows uninterrupted power or signal transfer between two stationary points. It is also known as an electric Rotary Joint, power swivel, or electrical rotary joint. Electric slip rings are usually composed of a metal ring with several brush contacts on the inner circumference. And there are one or more pairs of contacts for power or signals on the outer circumference. The metal ring can be rigid or flexible, depending on the application.


An electric slip ring is an electromechanical device that allows the transmission of electrical power and signals from a stationary to a rotating structure. It consists of an electrically conductive rotating disc or ring, with a number of electrical contacts (or "slots") on its surface. The contacts are connected to external circuits, enabling the passage of power and/or data from the stationary to the rotating structure. Slip rings are also used in generators, where they allow the passage of current from the rotor to the stator.


A flat disc electrical slip ring is one kind of electric slip ring, it has many advantages: simple construction, small size, low cost, easy installation, and maintenance. It is widely used in various fields such as machine tools, textile machinery, printing machinery, packaging machinery, medical equipment, and aerospace equipment.


A 360-degree rotating Conductive Slip Ring is also called a hollow shaft slip ring or hollow conduct. It has an opening in the center that allows a shaft to pass through, making it ideal for rotating applications. Slip rings are often used in medical equipment, robotics, and manufacturing assemblies where rotation is required. This type of slip ring can handle large currents and voltages while providing a continuous electrical connection.

Electric Slip Ring,Slip Rings In Generator,Flat Disc Electrical Slip Ring,Slip Ring Electric Motor

Dongguan Oubaibo Technology Co., Ltd. , https://www.sliprob.com