nginx动静分离
动静分离
Nginx负责处理客户端的静态文件的处理,让Tomcat专心处理动态的请求。主要配置看高亮处:
案例
server {
listen 80;
server_name 127.0.0.1;
index index.shtml
charset utf-8;
#access_log logs/host.access.log main;
location /module1 {
proxy_pass http://127.0.0.1:8080;
}
location /module1 {
proxy_pass http://127.0.0.1:8081;
}
location /module3 {
proxy_pass http://127.0.0.1:8082;
}
location /module4 {
proxy_pass http://127.0.0.1:8083;
}
location ~ ^/main/.*\.(html|htm|gif|jpg|jpeg|bmp|png|ico|txt|js|css)$ {
root /opt/package/tomcat7/eam-tomcat/webapps/;
expires 3d;
}
location ~ ^/module1/.*\.(html|htm|gif|jpg|jpeg|bmp|png|ico|txt|js|css)$ {
root /opt/package/tomcat7/bl-tomcat/webapps/;
expires 3d;
}
location ~ ^/module3/.*\.(html|htm|gif|jpg|jpeg|bmp|png|ico|txt|js|css)$ {
root /opt/package/tomcat7/cd-tomcat/webapps/;
expires 3d;
}
location ~ ^/module3/.*\.(html|htm|gif|jpg|jpeg|bmp|png|ico|txt|js|css)$ {
root /opt/package/tomcat7/df-tomcat/webapps/;
expires 3d;
}
}
上一篇: Make 命令教程