国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 網(wǎng)站 > Nginx > 正文

Nginx服務(wù)器中瀏覽器本地緩存和虛擬機(jī)的相關(guān)設(shè)置

2024-08-30 12:26:32
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

自動(dòng)列出目錄配置:

下載過開源軟件的都知道,一個(gè)很簡(jiǎn)單的頁(yè)面列出了所有版本的源碼包,這就是開啟了自動(dòng)列出目錄

如下配置,在虛擬主機(jī)location / {……}目錄控制中配置自動(dòng)列出目錄:
 

location / {  autoindex on;}

瀏覽器本地緩存設(shè)置:

瀏覽器是為了加速瀏覽,瀏覽器在用戶磁盤上對(duì)最近請(qǐng)求過的文件進(jìn)行存儲(chǔ),當(dāng)訪問者再次請(qǐng)求這個(gè)頁(yè)面,

瀏覽器可以從本地磁盤顯示文件,以達(dá)到加速瀏覽的效果,節(jié)約了網(wǎng)絡(luò)資源,提高了網(wǎng)絡(luò)效率

關(guān)鍵字: expires

默認(rèn)值: off

作用域: http,server.location

用途: 通過expires指令控制http應(yīng)答中的”Expires”和”Cache-Control”的頭信息

配置項(xiàng):

 

location ~ .*/.(gif|jpg|jpeg|png|bmp|swf)$    {        expires 30d;    }     location ~ .*/.(js|css)?$    {        expires 1h;    }


配置虛擬主機(jī):

  nginx可以配置多種類型的虛擬主機(jī),基于ip的 基于域名的 基于端口的,

簡(jiǎn)單一句話說就是不同ip相同端口,不同端口相同ip or域名,不同域名相同端口

下面是基于相同域名的虛擬主機(jī)配置文件:

 

server {    listen  80 default;     server_name www.wpython.com;     index index.html index.htm index.php;     root /alidata/www/www.wpython.com;     # wordpress 偽靜態(tài)規(guī)則    location / {      if (-f $request_filename/index.html){        rewrite (.*) $1/index.html break;    }       if (-f $request_filename/index.php){        rewrite (.*) $1/index.php;    }       if (!-f $request_filename){        rewrite (.*) /index.php;    }}    rewrite /wp-admin$ $scheme://$host$uri/ permanent;      location ~ .*/.(php|php5)?$    {        fastcgi_pass 127.0.0.1:9000;        fastcgi_index index.php;        include fastcgi.conf;    }     location ~ .*/.(gif|jpg|jpeg|png|bmp|swf)$    {        expires 30d;    }     location ~ .*/.(js|css)?$    {        expires 1h;    }    access_log /alidata/log/nginx/access/www.wpython.com.log;} server {    listen  80 default;     server_name www.pyyw.net;     index index.html index.htm index.php;     root /alidata/www/www.pyyw.net;     # wordpress 偽靜態(tài)規(guī)則    location / {      if (-f $request_filename/index.html){        rewrite (.*) $1/index.html break;    }       if (-f $request_filename/index.php){        rewrite (.*) $1/index.php;    }       if (!-f $request_filename){        rewrite (.*) /index.php;    }}    rewrite /wp-admin$ $scheme://$host$uri/ permanent;      location ~ .*/.(php|php5)?$    {        fastcgi_pass 127.0.0.1:9000;        fastcgi_index index.php;        include fastcgi.conf;    }     location ~ .*/.(gif|jpg|jpeg|png|bmp|swf)$    {        expires 30d;    }     location ~ .*/.(js|css)?$    {        expires 1h;    }    access_log /alidata/log/nginx/access/www.pyyw.net.log;}            
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 若羌县| 黄大仙区| 宁海县| 当涂县| 疏勒县| 藁城市| 林周县| 滨州市| 昭苏县| 习水县| 郴州市| 波密县| 襄垣县| 太和县| 五华县| 大竹县| 阳朔县| 和田市| 定襄县| 盖州市| 呼和浩特市| 克山县| 江源县| 鄂温| 恩施市| 石棉县| 静乐县| 万全县| 德江县| 霍城县| 梁山县| 武强县| 鲁甸县| 溧阳市| 思南县| 务川| 凤庆县| 石城县| 五家渠市| 财经| 凉山|