Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Nginx Tomcat static and dynamic separation experiment

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Nginx Static and Dynamic Separation Experiment

After installing Nginx and Tomcat, this experiment uses source code installation.

Related paths: 1. Nginx publishing path: /usr/local/nginx/html/colin12. Nginx virtual host configuration file: /usr/local/nginx/conf/vhost The configuration file reads as follows: server { listen 80; server_name www.colin1.com; location / { proxy_pass http://28.44.20.34:8080; } #Note location =/invalid must use location / location ~ .*\. (jpg|png|bmp|txt|js|css|html|htm|gif|ico|jpeg)$ { root html/colin1; } location ~ .*\. (jsp|cgi|shtml|php)$ { proxy_pass http://28.44.20.34:8080; Tomact Release Path: /data/web/tomact/webapps/ROOT

II. Problems encountered in the experiment

1. Use location =/invalid when defining the virtual host. You must use location /2. When the client accesses the jsp content, the jsp file will be located to the tomcat publishing path according to the location matching rule. When static content is invoked in jsp, it will be redirected to a url access. Take the jsp image tag as an example:

[tomcat logo]

#The essence is to visit https://cache.yisu.com/upload/information/20200309/28/26787.jpg3. The following is the whole access process of jsp:

Just like any other web page, your browser sends an HTTP request to the server.

The Web server recognizes that this is a request for a JSP page and passes the request to the JSP engine. This is done by using a URL or.jsp file.

The JSP engine loads JSP files from disk and converts them into servlets. This conversion simply changes all template text to println() statements and converts all JSP elements to Java code.

The JSP engine compiles the Servlet into an executable class and passes the original request to the Servlet engine.

A component of the Web server calls the Servlet engine, loads and executes the Servlet class. During execution, the Servlet produces output in HTML format and delivers it to the Web server embedded in the HTTP response.

The Web server returns the HTTP response to your browser as a static HTML page.

Eventually, Web browsers process HTML pages dynamically generated in HTTP responses as if they were static pages.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report