新聞中心

Nginx動(dòng)靜態(tài)分離

作者: 時(shí)間:2016-09-12 來(lái)源:網(wǎng)絡(luò) 收藏

worker_processes8;

本文引用地址:http://www.butianyuan.cn/article/201609/304226.htm

events {

use epoll;

worker_connections1024;

}

http {

includemime.types;

default_typeapplication/octet-stream;

sendfileon;

keepalive_timeout65;

gzipon;

upstream tomcats{

server 127.0.0.1:8080;}

server {

listen80 default_server;

server_nametest.tiao.xxx.com;

#訪問(wèn)/ROOT/下的static中的靜態(tài)文件

location ^~ /static/{

root/usr/local/tomcat/webapps/ROOT/;

}

location / {

#動(dòng)態(tài)程序丟給后端tomcat處理方

proxy_passhttp://tomcats;

}

error_page500 502 503 504/50x.html;

location = /50x.html {

roothtml;

}

}

#網(wǎng)站靜態(tài)資源交給后端CDN處理

server {

listen80;

server_name static.test.tiao.xxx.com;

location / {

root/usr/local/tomcat/webapps/ROOT/static/;

}

error_page500 502 503 504/50x.html;

location = /50x.html {

roothtml;

}

}

}



關(guān)鍵詞: Nginx 動(dòng)靜態(tài)分離

評(píng)論


技術(shù)專(zhuān)區(qū)

關(guān)閉