xsnow
机遇总是留给有准备的人
随笔 - 42,  文章 - 0,  评论 - 0,  阅读 - 75873

一、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
 

 

posted on   xsnow  阅读(2249)  评论(0编辑  收藏  举报
编辑推荐:
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
阅读排行:
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示