• Nginx第一天


    1.Nginx:是一款代理服务器,可以做反向代理,可以同时支撑5万以上并发量,占用内存和CUP资源较少,所以说大部分公司都用Nginx
    2.Nginx作用:
      1.Http服务器(反向代理)
      2.虚拟主机,静态服务器
      3.支持负载均衡,权重,轮训等等机制
      4.集群
      5.动静分离 静态资源,Nginx服务器管理静态资源,将静态资源放入nginx中,然后进行访问

    3.安全架构
      1.nginx可以做反向代理,不暴露真实IP地址
      2.使用HTTPS防止抓包分析HTTP请求
      3.搭建企业黑名单白名单(防盗链)
      4.模拟请求(csrf),xss攻击,sql注入
        csrf表单重复提交:攻击的是业务
      5.ddos流量攻击,频发的发送请求,占用的网络的带宽,一个IP频繁的发送请求,让别的用户访问不了 nginx

    4.反向代理服务器:Nginx服务器,lvs(中国人),F5通过硬件,HaProxy

    5.Nginx采用Http协议进行访问,默认端口为80
    nginx配置文件

    server {
                    listen       80;                    监听的端口
                    server_name  localhost;                访问的服务器名称
    
                    #charset koi8-r;
    
                    #access_log  logs/host.access.log  main;
    
                    location /a {
                        root   html;
                        index  index.html index.htm;
                    }
    
                    #error_page  404              /404.html;
    
                    # redirect server error pages to the static page /50x.html
                    #
                    error_page   500 502 503 504  /50x.html;
                    location = /50x.html {
                        root   html;
                    }
    
                    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
                    #
                    #location ~ .php$ {
                    #    proxy_pass   http://127.0.0.1;
                    #}
    
                    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
                    #
                    #location ~ .php$ {
                    #    root           html;
                    #    fastcgi_pass   127.0.0.1:9000;
                    #    fastcgi_index  index.php;
                    #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
                    #    include        fastcgi_params;
                    #}
    
                    # deny access to .htaccess files, if Apache's document root
                    # concurs with nginx's one
                    #
                    #location ~ /.ht {
                    #    deny  all;
                    #}
                }

    6.Nginx配置静态分离
      将静态资源放入到html文件夹内,重复服务器就可以访问了

    7.Nginx反向代理
      1.修改Hosts文件,暴露给外界一个地址
        127.0.0.1 www.wdksoft.com
      2.配置nginx反向代理,修改nginx.conf,思路如下:监听到客户端请求www.wdksoft.com 由内部进行资源转发

    server {
                    listen       80;            监听端口为80
                    server_name  www.wdksoft.com;    监听的域名
    
                    #charset koi8-r;
    
                    #access_log  logs/host.access.log  main;
    
                    location / {
                        proxy_pass http://localhost:8080/;        代理的地址
                        index index.html index.htm;                默认访问页面
                    }
                }

    8.Nginx集群负载均衡
    默认采用轮训机制,配置方式如下:

    upstream backserver { server localhost:8080; server localhost:8081; }
                server {
                    listen       80;
                    server_name  www.wdksoft.com;
    
                    #charset koi8-r;
    
                    #access_log  logs/host.access.log  main;
    
                    location / {
                        proxy_pass http://backserver;
                        index index.jsp index.htm;
                    }
                }

    权重比例配置

    upstream backserver { 
                    server localhost:8080 weight=2; 
                    server localhost:8081 weight=1; 
                }

    IP固定绑定,只能访问其中绑定的服务器

    upstream backserver { 
                    ip_hash;
                    server localhost:8080; 
                    server localhost:8081;
                }
  • 相关阅读:
    test
    【转载】ASP.NET MVC 3 —— Model远程验证
    【转载】富有客户端技术之——jQuery EasyUI
    【转载】基于ASP.NET Web Application的插件实现,附DEMO
    【转载】浅谈C#中的延迟加载(1)——善用委托
    【转载】Winform开发框架之权限管理系统
    【转载】基于我的Winform开发框架扩展而成的WCF开发框架
    [转载]10大优秀的移动Web应用程序开发框架推荐
    [转载]C#泛型列表List<T>基本用法总结
    [转载]推荐一个被大家忽视的微软的反跨站脚本库AntiXSS V3.1
  • 原文地址:https://www.cnblogs.com/ws1149939228/p/12283383.html
Copyright © 2020-2023  润新知