After configuring nginx, when accessing tomcat, it is found that tomcat displays the following picture:
As can be seen from this status, it is speculated that the css and js files may not be loaded.
Not only that, accessing pages deployed in tomcat projects is also the same. Different nginx accesses projects under tomcat like this:
Through nginx as a proxy server, the accessed page looks like this:
These situations are obvious This problem occurs because when nginx is used as a load balancing server, css and js files cannot be loaded normally. After some searching and searching, I modified the nginx.conf configuration file under nginx to display it normally. The modified configuration As follows:
Added such a configuration for loading css, js and image files.
The jsp_server in the above picture refers to the woolen cloth in the picture below, which is actually the upstream configuration.
Summary: nginx, as a load balancing server, can load css, js and image files normally. You need to add the loading of static files in the configuration file, that is, the configuration of the proxy_pass attribute. Maybe there are other better ways.
The above has introduced that Nginx cannot load css and js when doing load balancing, including the content of nginx and load balancing. I hope it will be helpful to friends who are interested in PHP tutorials.