美文网首页Nginx 服务器
Nginx的常见问题

Nginx的常见问题

作者: 全满 | 来源:发表于2018-10-16 10:49 被阅读6次
    • 相同server_name多个虚拟主机优先级访问
      • 例如:


        image.png

    小结:
    按照文件读取的顺序进行访问

    • location匹配优先级


      image.png
    • try_files使用


      image.png
    • Nginx的alias和root区别


      image.png
      image.png
    • 用什么方法传递用户的真实IP


      image.png
    • 其他


      image.png

    Nginx的性能优化

    • 性能优化考虑点
      • 当前系统结构瓶颈
        • 观察指标、压力测试
      • 了解业务模式
        • 接口业务类型、系统层次化结构
      • 性能与安全
    • 压测工具ab
      • 安装
        yum install httpd-tools
      • 使用
    ab -n 2000 -c 2 http://127.0.0.1/
    -n 总的请求数
    -c 并发数
    -k 是否开启长连接
    
    • 系统与Nginx性能优化
      • 网络
      • 系统
      • 服务
      • 程序
      • 数据库、底层服务

    SQL注入

    • 什么是SQL注入

    SQL注入攻击是黑客对数据库进行攻击的常用手段之一。随着B/S模式应用开发的发展,使用这种模式编写应用程序的程序员也越来越多。但是由于程序员的水平及经验也参差不齐,相当大一部分程序员在编写代码的时候,没有对用户输入数据的合法性进行判断,使应用程序存在安全隐患。用户可以提交一段数据库查询代码,根据程序返回的结果,获得某些他想得知的数据,这就是所谓的SQL Injection,即SQL注入。

    • SQL注入的场景


      image.png
      image.png

    Nginx的分类(三类)

    • 静态资源服务
    • 代理服务(负载均衡服务)
    • 动静分离

    windows的server配置与Linux的区别

    //windows
    server {
            listen       80;
            server_name  localhost;
    
            location / {
                alias   C:/Users/caoan/Desktop/nginx-1.14.0/html;
                index  index.html index.htm;
            }
            location /image/ {
                alias   C:/Users/caoan/Desktop/nginx-1.14.0/local/myImage/;
                autoindex on;
            }
    }
    
    image.png
    //linux
    server{
            listen       80;
            server_name  localhost;
    
            location / {
                root   html;
                index  index.html index.htm;
            }
            location /image/ {
                root   /usr/local/myImage/;
                autoindex on;
            }
    }
    
    image.png

    相关文章

      网友评论

        本文标题:Nginx的常见问题

        本文链接:https://www.haomeiwen.com/subject/vxhpaftx.html