關於nginx反向代理,是將jsp檔案轉交給tomcat處理,nginx主要處理靜態資源,nginx處理靜態資源的效率相對於tomcat高的多
在配置檔案如下部分:
location ~ \.jsp$
{
index index.jsp;
proxy_pass http://localhost: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 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 6 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
#自定義改變,將jsp的樣式返回
,這樣能夠實現我們想要的功能
location ~\.(html|gif|jpg|jpeg|png|bmp|swf|js|css)$
{
expires 30d;
root /www/server/tomcat/webapps/ROOT;
}
}