• Nginx 反向代理基本框架


    全局配置指令:
    user nginx;

    模块配置段
    # 事件驱动模块,提供并发响应功能
    events{
    ......
    }
    # http模块,提供web请求处理,可嵌套其他重要模块
    http{
    .......#server{}
    }

    开始配置:#备份nginx.conf ,清空文件
    # vim /etc/hosts 增加主机记录
    vim /etc/nginx/nginx.conf

    worker_processes 2; # 两个nginx进程
    events {
    worker_connections 1024; # 可同时处理1024个http请求
    }

    http {
    include mime.types; #调用mime ,可以处理多媒体
    default_type application/octet-stream;

    upstream test {
    # ip_hash; # 基于客户端的hash值进行请求分配
    server test1.com weight=10; # 权重负载
    server test2.com weight=20;
    }

    server {
    listen 80;
    server_name afan.com; # 用户输入网页先匹配到server{}中
    location / {
    proxy_pass http://test/index.html; # 扔给后端服务器,
    # html 是upstream的引用,先扔给 upstream html{}模块
    }
    }

    #############################################3
    server { #nginx至少有个虚拟主机才能工作
    listen 80;
    server_name Localhost; # 虚拟主机名称
    access_log /var/log/nginx/access_html.log html_log; #若localtion中,优先
    root html; # 网站主目录 ,一般是配置文件所在的目录

    location{}

    }
    }

    # 压力测试:# while true; do curl afan.com;done
    # shell : for i in `seq 1 20` ;do
    curl afan.com
    sleep 0.5
    done

  • 相关阅读:
    pgpoolII3.1 的内存泄漏(二)
    iOS 开发的一些网址
    ios开发必备第三方库
    iOS截屏方法
    ios开发第三方库cocoapods安装
    iOS开发知识点总结
    iOS开发文件夹Copy items if needed
    iOS开源库最全的整理
    iOS图标抖动效果
    iOS 加密的3种方法
  • 原文地址:https://www.cnblogs.com/wanzf/p/10654099.html
Copyright © 2020-2023  润新知