This article mainly introduces the implementation of nginx multiple locations forwarding any request or accessing static resource files, and shares it with you. The details are as follows: server { #Listening port listen 80; #The domain name to be listened to server_name localhost; #Listen to the URL with suffix location ^~\.txt { #Put the file in the /html folder root /; } #Listen to all URLs. If there is no special requirement, just use this location. #Use wildcards to enter location only if no other locations are matched / { #Removed the restriction that only URLs are forwarded, because directly accessing the domain name will not pass if and thus the request cannot be forwarded. proxy_pass http://localhost:8080; } } With matching rules: You will understand the rules if you try them yourself. The following is the original text↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ server { #Listening port listen 80; #The domain name to be listened to server_name localhost; #Listen to the URL with suffix location ^~\.txt { #Put the file in the /html folder root /; } #Monitor all URLs. If there is no special requirement, just use this location. location / { #Requests without a suffix are forwarded in order to cooperate with the previous location to access the resource file instead of forwarding all requests. If there is no special requirement, do not judge and directly proxy_pass to the request if (!-e $request_filename){ proxy_pass http://localhost:8080; break; } } } You can add multiple locations, but be careful not to conflict with each other, otherwise forwarding multiple requests will time out. This is the end of this article about the implementation of nginx multiple locations forwarding arbitrary requests or accessing static resource files. For more relevant content about nginx location forwarding arbitrary requests, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: ReactHooks batch update state and get route parameters example analysis
>>: Navicat Premium operates MySQL database (executes sql statements)
Introduction to jsvc In production, Tomcat should...
MySQL sequence AUTO_INCREMENT detailed explanatio...
Recent requirements: Global loading, all interfac...
Awk is a powerful tool that can perform some task...
Table of contents 1. Vertical (longitudinal) slic...
Today I will introduce to you a difference betwee...
Table of contents Preface InnoDB storage architec...
Docker is being used in more and more scenarios. ...
1. Export the database using the mysqldump comman...
Copy code The code is as follows: <!DOCTYPE ht...
Error description: 1. After installing Nginx (1.1...
Table of contents Preface 1. The significance of ...
Table of contents 1. Introduction 2. Implementati...
Preface This article mainly introduces the releva...
1. Reason I just needed to reinstall MySQL on a n...