Nginx dynamic and static separation implementation case code analysis

Nginx dynamic and static separation implementation case code analysis

Separation of static and dynamic

Dynamic requests and static requests are separated through middleware to reduce unnecessary request consumption.

Advantages: Dynamic and static services do not affect each other. If the dynamic service is stopped, static resources can still be accessed normally.

Examples

Simulation environment: lb01, web01 (simulation static server), web02 (simulation dynamic server)

1. Create a directory /pm_code/images/ on web01 and upload a picture

Configure the nginx file /etc/nginx/conf.d/static.conf:

2. Install tomcat on web02

yum -y install tomcat

systemctl start tomcat

The default port of tomcat is 8080. Confirm that it is opened normally:

mkdir /usr/share/tomcat/webapps/ROOT

Create a file random.jsp in this directory with the following content:

3. Create the configuration file ds.conf in /etc/nginx/conf.d/ on lb01 with the following content

Create /pm_code/ds/index.html with the following content:

5. Add in the local hosts file of the physical host: 192.168.1.5 ds.pm.com

6. Testing

Close the nginx service on web01 and refresh the page (use shift+F5 to force refresh and reconnect to prevent caching)

Open the nginx service of web01, close the tomcat service of web02, and refresh the page

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:
  • Basic configuration example of Nginx with Apache or Tomcat for dynamic and static separation
  • Using Nginx+uWsgi to separate the dynamic and static parts of Python's Django framework site
  • Simple implementation of nginx+tomcat reverse proxy and dynamic and static separation
  • Detailed explanation of nginx to separate static and dynamic tomcat
  • nginx realizes load balancing and dynamic and static separation
  • Nginx sample code for implementing dynamic and static separation
  • Detailed example of deploying Nginx+Apache dynamic and static separation
  • Sample code for nginx to achieve dynamic and static separation
  • Nginx implements dynamic and static separation example explanation
  • Detailed explanation of the process of realizing dynamic and static separation in Springmvc nginx
  • Docker Nginx container and Tomcat container to achieve load balancing and dynamic and static separation operations
  • Analysis of the principle of Nginx+Tomcat to achieve load balancing and dynamic and static separation
  • The principle and configuration of Nginx load balancing and dynamic and static separation
  • Example of how nginx implements dynamic and static separation
  • Detailed instructions for nginx from installation to configuration (installation, security configuration, anti-hotlinking, dynamic and static separation, HTTPS configuration, performance optimization)
  • Implementation of Nginx+Tomcat load balancing and dynamic and static separation cluster
  • Server load balancing nginx+tomcat to achieve dynamic and static separation
  • Nginx dynamic and static separation configuration implementation and description

<<:  Summary of Vue3 combined with TypeScript project development practice

>>:  Solution to the problem of MySQL data delay jump

Recommend

Analysis of the process of deploying Python applications in Docker containers

Simple application deployment 1. Directory struct...

Detailed explanation of PHP+nginx service 500 502 error troubleshooting ideas

Overview When a 500 or 502 error occurs during ac...

In-depth analysis of MySQL index data structure

Table of contents Overview Index data structure B...

JavaScript to achieve the effect of tab bar switching

Tab bar: Click different tabs to display differen...

Detailed explanation of MYSQL large-scale write problem optimization

Abstract: When people talk about MySQL performanc...

Detailed explanation of MySQL deadlock and database and table sharding issues

Record the problem points of MySQL production. Bu...

How to install docker and portainer in kali

With the emergence of docker, many services have ...

Tutorial on how to remotely connect to MySQL database under Linux system

Preface I recently encountered this requirement a...

iview implements dynamic form and custom verification time period overlap

Dynamically adding form items iview's dynamic...

Detailed explanation of the use of Vue image drag and drop zoom component

The specific usage of the Vue image drag and drop...

How to deploy nextcloud network disk using docker

NextCloud You can share any files or folders on y...

Detailed explanation of the use of MySQL paradigm

1. Paradigm The English name of the paradigm is N...