2025年3月24日 星期一 甲辰(龙)年 月廿三 设为首页 加入收藏
rss
您当前的位置:首页 > 计算机 > 服务器 > Nginx

nginx 常用的中间件

时间:07-04来源:作者:点击数:37

1.--with-http_stub_status_module nginx客户端状态

  • # 打开default.conf文件
  • vim /etc/nginx/conf.d/default.conf
  • # 添加 到default.conf 文件中
  • location /mystatus {
  • stub_status;
  • }
  • # 检查配置是否正确
  • nginx -tc /etc/nginx/nginx.conf
  • # 重载配置文件
  • nginx -s reload -c /etc/nginx/nginx.conf

2. --with-http_random_index_module 目录中随机选择一个主页 

  • # 打开default.conf文件
  • vim /etc/nginx/conf.d/default.conf
  • # 添加 到default.conf 文件中
  • location /(所有路径) {
  • root /usr/share/nginx/html; # 首页页面的路径
  • random_index on; (随机选择一个主页)
  • # index index.html index.htm; # 首页访问的那个页面
  • }
  • # 检查配置是否正确
  • nginx -tc /etc/nginx/nginx.conf
  • # 重载配置文件
  • nginx -s reload -c /etc/nginx/nginx.conf

3.--with-http_sub_module  http内容替换

  • # 打开default.conf文件
  • vim /etc/nginx/conf.d/default.conf
  • # 添加 到default.conf 文件中
  • location /(所有路径) {
  • root /usr/share/nginx/html; # 首页页面的路径
  • index index.html index.htm; # 首页访问的那个页面
  • sub_filter '<a>imoce' '<a>ccc'; # <a>imoce替换成<a>ccc
  • sub_filter_onece off; # 全部替换 默认替换第一个
  • }
  • # 检查配置是否正确
  • nginx -tc /etc/nginx/nginx.conf
  • # 重载配置文件
  • nginx -s reload -c /etc/nginx/nginx.conf
方便获取更多学习、工作、生活信息请关注本站微信公众号城东书院 微信服务号城东书院 微信订阅号
推荐内容
相关内容
栏目更新
栏目热门