1. Priority of multiple servers For example, if each server block listens to port 80, www.pm.com corresponds to the server IP address, and the matching order is: ①The block where server_name is exactly the same as www.pm.com. ②The block where server_name is *.pm.com. (wildcard first) ③The block where server_name is pm.*. (wildcard after) ④server_name uses a regular expression and can match the block of www.pm.com. ⑤If no match is found, the block of listen 80 default_server; will be selected. ⑥If there is no item 5, select the first server block of the first configuration file. When you visit the domain name www.pm.com, the above server will be given priority. If you access it with IP at this time, the value of the Host field in the request header is 192.168.1.7, and it cannot match server_name. It will match the server below according to the rules. 2. Prohibit IP access Prohibiting IP access can prevent others from maliciously resolving the domain name to their own IP. Two forms: Note: The first method must use default_server. If you need to use default_server elsewhere, you can use the second method. 3. Use include more often (write good comments) Configuring multiple server websites on one server will make the main configuration file nginx.conf very bloated and difficult to read. In this case, you can use the include method more often to simplify the main configuration file and make it easier for operation and maintenance personnel to maintain it. 4. Use alias to protect the real directory structure of the website When we access the image at http://www.pm.com/image/logo.png, the visitor will know the path to the image.
The corresponding path is /pm_code/image/ When using alias:
At this time, the actual location of the image is under /pm_code, /image is a virtual directory, and the alias is followed by the absolute directory path. 5. Error_page configuration Simulate 404 error When you enter a non-existent URL, such as http://www.pm.com/jfkdjfk, it will jump to /pm_code/www/404.jpg Simulate 502 error Enter www.pm.com in the browser, the link will time out, and /pm_code/www/500.jpg will be displayed NOTE: The format is different between the two. 500 You must write another location. 6.try_files configuration A simple example: When you enter www.pm.com in the browser, it will first look for 400.html, and if it is not there, it will then look for index.html The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: React+ts realizes secondary linkage effect
>>: How to declare a cursor in mysql
I use tengine, the installation directory is /usr...
Effect display The built-in boot interface is too...
Table of contents Preface What is VueUse Easy to ...
1. --cpu=<value> 1) Specify how much availa...
On a Linux computer, there are two times, one is ...
Table of contents 1. First install echarts in the...
Click here to return to the 123WORDPRESS.COM HTML ...
CentOS 8 has been released for a long time. As so...
<br />Related article: Analysis of Facebook&...
Table of contents 1. Pull the image 2. Create a l...
(1) Introduction: clipboard.js is a lightweight J...
This article briefly introduces how to install My...
1. Overview of modules and instructions used to l...
I'm playing with big data recently. A friend ...
1. Problem reproduction: Count the total number o...