nginx与tomcat 组合 实现静态文件和jsp组合访问

主要修改nginx的配置文件:

设置代理

location /{
proxy_pass http://47.94.158.2:8080;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 30;
proxy_send_timeout 30;
proxy_read_timeout 30;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
}

缓存静态文件:

location ~ \.(js|css|gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
root /usr/java/tomcat/tomcat/webapps/ROOT;
}

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
root /usr/java/tomcat/tomcat/webapps/ROOT;
}

location ~ .*\.(js|css)?$
{
expires 12h;
root /usr/java/tomcat/tomcat/webapps/ROOT;
}

上一篇:(转)nginx利用geo模块做限速白名单以及geo实现全局负载均衡的操作记录


下一篇:Springboot使用Shiro-整合Redis作为缓存 解决定时刷新问题