search

Home  >  Q&A  >  body text

Regarding the dynamic separation of Nginx and Tomcat and the problem of load balancing configuration files

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? ?

滿天的星座滿天的星座2751 days ago529

reply all(2)I'll reply

  • 大家讲道理

    大家讲道理2017-05-16 17:20:23

    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.

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-05-16 17:20:23

    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?

    reply
    0
  • Cancelreply