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
Body part: <button>Turn on/off light</bu...
1. The emergence of the problem Wrote a flat list...
When position is absolute, the percentage of its ...
CSS writing order 1. Position attributes (positio...
This article example shares the specific code of ...
Table of contents 1. Tool Introduction 2. Workflo...
At this time, you can use overflow:auto; (when the...
Table of contents Nginx proxies two socket.io ser...
In order to make the table fill the screen (the re...
This article example shares the specific code of ...
Table of contents 1. What is Promise 2. Basic usa...
You can use the ps command. It can display releva...
As early as in the CSS2 recommendations in 1998, t...
Introduction Recently, I needed to make a barrage...
Basic knowledge of responsive layout development ...