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

首頁 > 網站 > 建站經驗 > 正文

Nginx服務器中瀏覽器本地緩存和虛擬機的相關設置

2019-11-02 15:54:57
字體:
來源:轉載
供稿:網友

自動列出目錄配置:

下載過開源軟件的都知道,一個很簡單的頁面列出了所有版本的源碼包,這就是開啟了自動列出目錄

如下配置,在虛擬主機location / {……}目錄控制中配置自動列出目錄:

 

location / {  autoindex on;}

瀏覽器本地緩存設置:

瀏覽器是為了加速瀏覽,瀏覽器在用戶磁盤上對最近請求過的文件進行存儲,當訪問者再次請求這個頁面,

瀏覽器可以從本地磁盤顯示文件,以達到加速瀏覽的效果,節約了網絡資源,提高了網絡效率

關鍵字: expires

默認值: off

作用域: http,server.location

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

配置項:

 

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

配置虛擬主機:

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

簡單一句話說就是不同ip相同端口,不同端口相同ip or域名,不同域名相同端口

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

 

server {    listen  80 default;     server_name www.wpython.com;     index index.html index.htm index.php;     root /alidata/www/www.wpython.com;     # wordpress 偽靜態規則    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 偽靜態規則    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;}

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 洪湖市| 上饶县| 丹巴县| 甘肃省| 永康市| 南溪县| 白城市| 枣阳市| 禹州市| 揭东县| 丰都县| 滕州市| 文水县| 库尔勒市| 东阳市| 子洲县| 宣城市| 新巴尔虎左旗| 泾源县| 清镇市| 太仆寺旗| 乳源| 清丰县| 义马市| 神农架林区| 鹤山市| 平罗县| 扎赉特旗| 珲春市| 莱州市| 沅陵县| 贵南县| 永济市| 定边县| 信宜市| 临漳县| 邵阳市| 礼泉县| 安乡县| 南华县| 通辽市|