一、nginx核心配置:nginx.conf文件配置如下: #这里的 upstream和下边server_name要一致 都是"localhost"表示本地,也可以是网站域名(注意不包括http://) upstream localhost_tomcat { server 172.16.4.79:8888; server 172.16.4.79:8889; } server { listen 80; #charset koi8-r; #access_log logs/host.access.log main; #自己指定要跳转的域名 server_name localhost; #下边是静态资源配置,放在nginx服务器下,在目录resources/ROOT底下。 location ~ .*\.(html|htm|gif|jpg|jpeg|bmp|png|ico|txt|js|css)$ { root resources/ROOT; #expires定义用户浏览器缓存的时间为7天,如果静态页面不常更新,可以设置更长,这样可以节省带宽和缓解服务器的压力 expires 7d; location / { #此处配置的域名必须与upstream的域名一致,才能转发。 proxy_pass http://localhost_tomcat; #root html; #index index.html index.htm; } }