ngin攔截一個指定的html頁面以及常用命令


一、nginx攔截一個指定的html頁面

server {

  ...

  # 攔截指定頁面,~* 是不區分大小寫,~ 區分大小寫,攔截后重寫地址,參數會一起傳入重寫地址,重寫地址可以是另一個頁面,也可以是服務接口地址
  if ($request_uri ~* "tyg.html") {
     # rewrite ^/ http://tyg.com/templates/tygController;   // 重定向

     return 404;      // 返回404

   }

  ...

}

二、nginx常用命令

1、查找nginx所在位置:whereis nginx

2、查看nginx狀態:systemctl status nginx.service

3、啟動、停止、重載命令

systemctl start nginx.service
systemctl stop nginx.service
systemctl reload nginx.service
systemctl status nginx.service
4、查看端口占用情況:netstat -antp | grep :端口號
5、查看所有端口占用情況:netstat -antp | grep :
6、查看nginx進程運行狀態:ps aux | grep nginx
     過慮grep本身:ps aux | grep :80 | grep -v grep
7、查看版本:nginx -V
 
三、nginx不能訪問非80端口
原因:防火牆沒有開非80端口
 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM