日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > Nginx >内容正文

Nginx

Nginx添加ngx_http_headers_module模块

發布時間:2024/1/23 Nginx 385 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Nginx添加ngx_http_headers_module模块 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

? ? 今天由于公司微信端添加地圖業務,但地圖不支持https,所以將https改為http訪問,因此出現訪問異常,原因是之前訪問的用戶,微信端存在緩存頁面,但是不會清楚,所以我就提出,可以在nginx在主機頭跳轉的時候做清楚緩存的操作,讓微信端訪問時,響應頭不存儲緩存,這樣就解決問題了,下面是配置的過程(配置很簡單,但是這個過程我花了1天的時間,如果有坑,請留言)

官方文檔:http://nginx.org/en/docs/http/ngx_http_headers_module.html

1.查看檔期啊nginx版本及確認安裝目錄

cd /home/oldboy/tools/ wget -q http://nginx.org/download/nginx-1.8.1.tar.gz tar xf nginx-1.8.1.tar.gz cd nginx-1.8.1

版本及目前使用的模塊信息

[root@web01 extra]# /application/nginx/sbin/nginx -V nginx version: nginx/1.8.1 built by gcc 4.4.7 20120313 (Red Hat 4.4.7-17) (GCC) built with OpenSSL 1.0.1e-fips 11 Feb 2013 TLS SNI support enabled configure arguments: --with-http_stub_status_module --with-http_ssl_module --prefix=/application/nginx-1.8.1/ ###注意一定要事先查看當前nginx下有哪些編譯模塊,記錄,然后與要添加的模塊一起編譯

2.下載headers模塊

cd /home/qiuyuetao/ wget https://codeload.github.com/openresty/headers-more-nginx-module/zip/master\ unzip headers-more-nginx-module-master.zip

3.記錄下當前訪問頁面的狀態(也可以在web頁面上查看 響應頭信息)

[root@web01 qiuyuetao]# curl -I www.etiantian.org HTTP/1.1 301 Moved Permanently Server: nginx/1.2.9 Date: Wed, 02 Aug 2017 06:17:47 GMT Content-Type: text/html Content-Length: 184 Connection: keep-alive Location: ###這里可以修改內容很多,只是用到里面的一點點知識,其它內容,大家可以科普##

4.將header模塊,編譯到nginx中去

cd /home/qiuyuetao/tools/nginx-1.8.1 ##這個下載的安裝文件目錄 ./configure --with-http_stub_status_module --with-http_ssl_module --prefix=/application/nginx-1.8.1/ --add-module=/home/qiuyuetao/headers-more-nginx-module-master ###注意一定要事先查看當前nginx下有哪些編譯模塊,記錄,然后與要添加的模塊一起編譯## make

(如果現在已經部署了nginx?就不能make install?,如果沒有部署nginx 可以make install)

5.替換nginx啟動文件 (yo)

cd /application/nginx/sbin mv nginx{,.bak} cp nginx /application/nginx/sbin/ ##這個是將重新編譯的nginx 配置文件,復制到安裝目錄使新的模塊生效

6.重啟服務,測試是否正常

/application/nginx/sbin/nginx -s stop /application/nginx/sbin/nginx /application/nginx/sbin/nginx -V

7.驗證效果

[root@web01 qiuyuetao]# /application/nginx/sbin/nginx -V nginx version: nginx/1.8.1 built by gcc 4.4.7 20120313 (Red Hat 4.4.7-17) (GCC) built with OpenSSL 1.0.1e-fips 11 Feb 2013 TLS SNI support enabled configure arguments: --with-http_stub_status_module --with-http_ssl_module --prefix=/application/nginx-1.8.1/ --add-module=/home/qiuyuetao/headers-more-nginx-module-master

8.添加到nginx 指定站點配置文件中

server{listen 80;server_name www.etiantian.org;location / { ##將下面header信息寫入location下 ## max-age設定緩存時間 nocashe 就是不緩存 add_header Cache-Control no-cache; add_header Cache-Control no-store; add_header Pragma no-cache; add_header Expires 0; }

9.重新加載

/application/nginx/sbin/nginx -s stop/application/nginx/sbin/nginx

##web頁面查看結果##

?

?

總結

以上是生活随笔為你收集整理的Nginx添加ngx_http_headers_module模块的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。