Nginx cannot load css and js when doing load balancing. Zhang Yan f5 load balancing nginx tcp load balancing

WBOY
Release: 2016-07-29 08:50:30
Original
1837 people have browsed it

After configuring nginx, when accessing tomcat, it is found that tomcat displays the following picture:

nginx负载均衡配置,nginx,nginx负载均衡策略,nginx tomcat负载均衡,nginx负载均衡原理,负载均衡,张宴,f5 负载均衡,nginx tcp 负载均

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:

nginx负载均衡配置,nginx,nginx负载均衡策略,nginx tomcat负载均衡,nginx负载均衡原理,负载均衡,张宴,f5 负载均衡,nginx tcp 负载均

Through nginx as a proxy server, the accessed page looks like this:

nginx负载均衡配置,nginx,nginx负载均衡策略,nginx tomcat负载均衡,nginx负载均衡原理,负载均衡,张宴,f5 负载均衡,nginx tcp 负载均

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:

nginx负载均衡配置,nginx,nginx负载均衡策略,nginx tomcat负载均衡,nginx负载均衡原理,负载均衡,张宴,f5 负载均衡,nginx tcp 负载均

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.

nginx负载均衡配置,nginx,nginx负载均衡策略,nginx tomcat负载均衡,nginx负载均衡原理,负载均衡,张宴,f5 负载均衡,nginx tcp 负载均

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.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!