Regarding the dynamic separation of Nginx and Tomcat and the problem of load balancing configuration files
滿天的星座
滿天的星座 2017-05-16 17:18:23
0
2
525

Xiaobai sincerely asks for advice
The picture above is the configuration file of Nginx
If you write this in index.jsp: <img src="img/test.png" >
This is the implementation Is load balancing done?
If not, how should I configure it?
When this img/test.png image is loaded in the browser, is it looking for resources in tomcat or Nginx cached resources? ?

滿天的星座
滿天的星座

reply all(2)
大家讲道理

First of all, with this configuration, you only realize that the image resources are processed directly by nginx.

But, but, but, what about ajax requests? What about front-end js, css and .ttf? Do you still want to write?

I am usually the first one

location /{
    proxy_pass http://myserver.com #对应的upstream
}

Then one more rule above this

location /resources{
root /opt/web/xxxproject
}

In this way, except for requests starting with /resources, the rest will be transferred to the tomcat instance behind for processing.

Randomly written chestnuts, a search on the Internet, there are too many explanations on various configurations.

伊谢尔伦

Dynamic and static separation means that the application server such as tomcat handles dynamic requests, and nginx handles static requests. You can stop tomcat to test whether nginx is working. This has nothing to do with load balancing, right?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template