1. 程式人生 > >nginx動靜分離小示例

nginx動靜分離小示例

lis span gin 其他 cati cal 分離 log root

     server {
        listen       80;
        server_name  www.xxx.cn;
    
     #靜態頁面
     #匹配首頁,url:www.xxx.cn index index.html; root
/usr/local/nginx/html/admin/;
     #匹配樣式 location
~ .*\.(html|htm|gif|jpg|jpeg|bmp|png|ico|txt|js|css|font|ttf)$ { root /usr/local/nginx/html/admin/; }
#動態頁面
     #匹配其他URL(除了首頁和樣式之外的url)
     #[a-z]+: 多個a-z字符。 location
~* /[a-z]+/ { #root /usr/local/nginx/html/admin/; proxy_pass http://tadmin_shujuzhihui; # try_files $uri/ /index.html; } error_page 502 = /404.html; }

nginx動靜分離小示例