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

参考网址:https://www.cnblogs.com/hailang8/p/8664413.html

三、nginx不能访问非80端口

原因:防火墙没有开非80端口

防火墙参考网址:https://www.cnblogs.com/taiyonghai/p/5825578.html