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

Page Speed ​​Optimization at a Glance

I believe that the Internet has become an increas...

Let's talk about the size and length limits of various objects in MySQL

Table of contents Identifier length limit Length ...

202 Free High Quality XHTML Templates (1)

Here 123WORDPRESS.COM presents the first part of ...

Getting Started Guide to MySQL Sharding

Preface Relational databases are more likely to b...

Use of align-content in flex layout line break space

1. The effect diagram implemented in this article...

Vue implements simple slider verification

This article example shares the implementation of...

JavaScript array deduplication solution

Table of contents Method 1: set: It is not a data...

How to View All Running Processes in Linux

You can use the ps command. It can display releva...

HTML n ways to achieve alternate color code sample code

This article mainly introduces the sample code of...

js canvas realizes circular water animation

This article example shares the specific code of ...

Bootstrap 3.0 study notes buttons and drop-down menus

The previous article was a simple review of the B...

How to draw a vertical line between two div tags in HTML

Recently, when I was drawing an interface, I enco...

Detailed process of installing and configuring MySQL and Navicat prenium

Prerequisite: Mac, zsh installed, mysql downloade...