最近在工作当中需要使用nginx,就对nginx进行进一步的了解,测试。

       工作需求是在微服务架构的基础上,客户端通过nginx反向代理访问服务端,确保当一个服务端出现问题时能及时切换到正常工作的服务端。测试使用nginx-1.13.2.rar,官网地址为:http://www.nginx.org/;测试使用的ip服务端为:10.74.214.109:8088、10.74.214.109:8091,服务端启动时的端口为8090;程序首页的路径为:"D:\cloudCode\internet\CoreToolWebPortal\01.CoreToolWebPotalWeb"下的index.html文件
  将nginx解压包放在C盘根目录下:
  编辑修改nginx.conf文件,如下:
 
  #Nginx用户组。windows下不指定;
  #user  nobody;
 
     #工作进程:数目。根据硬件调整,通常等于CPU数量,或者2倍于CPU;
     worker_processes  1;
 
     #pid        logs/nginx.pid;
 
 
   events {
        #每个工作进程的最大连接数量,根据硬件调整,和前面工作进程配合起来使用,尽量大,
        #但是别把CPU跑到100%就行。
        #每个进程允许的最多连接数,理论上没台nginx服务器的最大连接数       
        #为:worker_process*worker_connections
       worker_connections  1024;
       }
 
       #设定http服务器,利用它的反向代理功能提供负载均衡支持
       http {
           # 设定mime类型,类型由mime.type文件定义
           include       mime.types;
           default_type  application/octet-stream;
 
           #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
           #                  '$status $body_bytes_sent "$http_referer" '
           #                  '"$http_user_agent" "$http_x_forwarded_for"';
 
           #access_log  logs/access.log  main;
 
           sendfile        on;
           #tcp_nopush     on;
 
           #keepalive_timeout  0;
           keepalive_timeout  65;
 
           #gzip  on;
 
           #负载均衡地址
           upstream  api_server{
                 #server 10.74.214.109:8091 weight=1 max_fail=3 fail_timeout=30;
                 server   10.74.214.109:8091;
                 server   10.74.214.109:8088 backup;#热备
           }
 
           server {
                 listen       8090;#备注:启动服务器的端口为这个;
 
                 #配置访问域名
                 server_name  localhost;
 
                 #charset koi8-r;
 
                 #access_log  logs/host.access.log  main;
 
                 location / {
                 root  "D:\cloudCode\internet\CoreToolWebPortal\01.CoreToolWebPotalWeb";
                 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;
        #}
 
 
 
 
        #实现反向代理
        location ~* ^/services/.*{
             #请求的主机域名
             proxy_set_header  Host  $host;
             
             #转的目标ip   
             proxy_set_header  X-Real-IP  $Remote_addr;
 
 
             #转发的目标
             proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
 
             #禁止缓冲
             proxy_buffering  off;
 
             #代理地址
             proxy_pass   http://api_server;
 
       }
    }
 
 
    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;
 
    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}
 
 
    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;
 
    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;
 
    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;
 
    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;
 
    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}
 
 
 
}
 
 
      运行nginx:cmd->cd ../..->cd nginx-1.13.2->start nginx.exe
      由于时在公司测试的运行,公司出于保密需要截图不允许外发,暂不将测试的截图贴上,敬请谅解!

nginx测试小结的更多相关文章

  1. springboo+nginx测试反向代理02

    本节对nginx配置方面会略微研究~~ 1:切换到 /opt/nginx-1.8.1/conf 目录,将nginx.conf文件拷贝到 /myprojects/nginx 目录下 2:切换到/opt/ ...

  2. Nginx 测试环境配置,留作笔记使用

    Nginx 测试环境配置,留做笔记 以下全是配置文件的配置,如果有疑问还请移步Nginx官网参考官方文档. 环境: [root@CentOS6-M01 conf]# cat /etc/redhat-r ...

  3. web测试小结

    今年5月份开始接触web测试,经过大半年的测试及学习,简单总结下 测试过程: 1.需求理解 2.测试策略.方案.用例编写及评审 3.测试环境搭建 4.测试执行 5.bug提单.问题跟踪 6.回归测试 ...

  4. 基于USB3.0的双目相机测试小结之CC1605配合CS5642 双目 500w摄像头

    基于USB3.0的双目相机测试小结之CC1605配合CS5642  双目 500w摄像头 CC1605双目相机评估板可以配合使用柴草电子绝大多数摄像头应用 如:OV5640.OV5642.MT9P03 ...

  5. iSensor APP 之 摄像头调试 MT9D001 MT9P031 测试小结 200万像素和500万像素摄像头

    iSensor APP 之 摄像头调试  MT9D001 MT9P031 测试小结 iSensor app 非常适合调试各种摄像头,已测试通过的sensor有: l  OV7670.OV7725.OV ...

  6. 关于搭建一个高性能网站的服务器的架设思路以及nginx测试的并发

    对于高性能网站的架设,主要就是请求量大,那我们该如何进行支撑? 考虑到下面的几个方面: 1.要减少请求,那对于开发人员来说,网站的css文件进行合并,背景图片也要合并,一般都是请求一张比较大的图片,然 ...

  7. Nginx配置小结

    前两天区听了一堂Nginx的课,然后翻了一下自己之前的Nginx的笔记,做了一个简单的小结. 全局变量 $args : 这个变量等于请求行中的参数,同$query_string $content_le ...

  8. springboo+nginx测试负载均衡

    1:之前只是用nginx调用了boot_8044这一个服务,这次新建一个boot_8055服务,并在linux上启动: 两个boot我都是放在 /myprojects 目录下的(自定义,能启动就行) ...

  9. Nginx 经验小结

    chmod 777 永远不要 使用 777,有时候可以懒惰的解决权限问题, 但是它同样也表示你没有线索去解决权限问题,你只是在碰运气. 你应该检查整个路径的权限,并思考发生了什么事情. 把 root ...

随机推荐

  1. 虚拟机U盘挂载

    虚拟机中U盘挂载 一.连接U盘 虚拟机中    虚拟机→可移动设备→Syntek USB......(U盘的名称)→连接: 二.查看U盘的UUID “lsblk -f”: UUID为   35E6-9 ...

  2. cin与cout格式化输出

    cin 中“<<”流 输入运算符 ----------------------------------------------------------------------------- ...

  3. python中time模块常用功能

    import time time模块提供了大量对时间进行处理的方法 time.time() # 获取当前时间戳,得到自1970年开始的秒数 >>>time.time() 155487 ...

  4. XXS level10

    (1)进入第十关发现无突破口,尝试从url中的keyword入手,也行不通,但可以从页面源代码看到有三个参数是隐藏的 (2)查看PHP源代码 <?php ini_set("displa ...

  5. Codeforces1076E. Vasya and a Tree(dfs+离线+动态维护前缀和)

    题目链接:传送门 题目: E. Vasya and a Tree time limit per test seconds memory limit per test megabytes input s ...

  6. javascript继承的6种方法

    1原型式继承 简介:对类式继承的封装,过渡对象相当于子类. function inheritObject(o) { //声明过渡函数对象 function F() {} //过渡对象的原型继承父类 F ...

  7. 2018.4.26 lvm

    lvm(Logical Volume Manager)逻辑卷管理,是Linux环境下对磁盘分区进行管理的一种机制. 基本概念: 1. 物理卷-----PV(Physical Volume)物理卷在逻辑 ...

  8. Windows7 密码修改

    一:不用输入原密码的方式修改用户的密码 1 命令行输入命令:mmc  #进入到控制台 2 点击左上角的文件,选择添加/删除管理单元 3 选择本地用户和组管理单元,添加到本地计算机,完成,确定 4 添加 ...

  9. [R] t.test()

    t.test(x, y = NULL, alternative = c("two.sided", "less","greater"), mu ...

  10. 简单的shell脚本练习(一)

    1:求1000一内的偶数和 方法一: #!/bin/bash #用累加实现1000以内的偶数和 sum= ;i<=;i=i+)) do sum=$(($sum+$i)); done echo $ ...