zoukankan      html  css  js  c++  java
  • nginx企业级优化

    配置nginx隐藏版本号

    • 获取网站信息

      curl -I http://192.168.200.18
      server:nginx/1.8.0  #网站应用以及版本号
      
    • 修改源码包

      #安装nginx,直到解压到目录步骤中
      cd /usr/src/nginx-1.14.2/
      vim src/core/nginx.h
        #define NGINX_VERSION      "1.11.1"    #版本号
        #define NGINX_VER          "apche/" NGINX_VERSION    #应用名称
      #编译安装
      ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx && make && make install
      #启动查看
      curl -I http://192.168.200.19
      server:apche/1.11.1
      
    • 修改配置文件

      vim /usr/local/nginx/conf/nginx.conf
      28  server_tokens  off;  #添加隐藏版本配置
      #启动查看
      curl -I http://192.168.200.19
      server:nginx
      

    修改nginx的用户和组

    • 在编译安装是指定
      ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx && make && make install

    • 修改配置文件

      在nginx.conf中添加user  nginx nginx;
      

    配置页面缓存时间

    • nginx将页面放回客户端时,设置缓存页面时间,以方便客户在日后进行统一操作时,方便返回。一般只针对静态页面。
      #配置方法,在http段,server段,location段配置过期参数
      location ~ .(gif|jpg|jpeg|gng|bmp|ico)$ {
                    expires 1d;
            }
       #页面中以上述结尾的文件缓存一天
            location ~ .*.(js|css)$ {
                    expires 1h;
            }
        #页面中以上述结尾的文件缓存一小时
      
      #重启nginx
      自行检测添加图片fiddler抓包日志软件
      

    nginx日志切割

    • nginx日志
      [root@hostlocal html]# ls -l   /usr/local/nginx/logs/
      总用量 96
      -rw-r--r--. 1 root root 56896 9月  15 18:50 access.log
      -rw-r--r--. 1 root root 36459 9月  15 18:46 error.log
      -rw-r--r--. 1 root root     5 9月  15 18:32 nginx.pid
      
      
    • datetime命令
      
      
  • 相关阅读:
    粘性固定 position:sticky
    vue组件样式scoped
    vue组件结构
    vue根据路由判断所在的内容
    配置系统变量
    div中放入一个img元素导致div高度会多出几个像素
    button标签设置line-height问题
    Netty学习——protoc的新手使用流程
    Netty学习——Google Protobuf的初步了解
    Netty学习——Google Protobuf使用方式分析和环境搭建
  • 原文地址:https://www.cnblogs.com/wml3030/p/15292300.html
Copyright © 2011-2022 走看看