最近在工作当中需要使用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. MVC+三层+ASP.NET简单登录验证

    通过制作一个登录小案例来搭建MVC简单三层 在View --Shared下创建一个母版页: <!DOCTYPE html> <html> <head> <me ...

  2. linux权限相关操作

    Linux权限管理是Linux中一个十分重要的概念,也是系统安全性的重要保障.这里主要介绍Linux的基本权限和默认权限,通过理论讲解与实验演示,可以详细了解到权限的相关操作及其重要性. 文件权限 [ ...

  3. C语言求行列式的值

    #include "stdafx.h" #include <stdio.h> #include <stdlib.h> #include <window ...

  4. Nmap使用指南

    一.目标指定 1.CIDR标志位 192.168.1.0/24 2.指定范围 192.168.1.1-255 192.168.1-255.1(任意位置) 3.IPv6地址只能用规范的IPv6地址或主机 ...

  5. hdu5001 Walk 概率DP

    I used to think I could be anything, but now I know that I couldn't do anything. So I started travel ...

  6. 【SpringBoot】整合Redis实战

    ========================9.SpringBoot2.x整合Redis实战 ================================ 1.分布式缓存Redis介绍 简介: ...

  7. 数学:确定性的丧失 (M·克莱因 著)

    第一章 数学真理的起源 (已看) 第二章 数学真理的繁荣 (已看) 第三章 科学的数学化 (已看) 第四章 第一场灾难:真理的丧失 (已看) 第五章 一门逻辑科学不合逻辑的发展 (已看) 第六章 分析 ...

  8. python中的copy.copy和copy.deepcopy

    一个例子就搞清楚 import copy a = [1, 2, 3, 4, ['a', 'b']] #原始对象 b = a #赋值,传对象的引用 c = copy.copy(a) #对象拷贝,浅拷贝 ...

  9. ubuntu18.04安装openresty

    ubuntu18.04使用openresty官方APT源安装openresty 添加openresty的 APT 仓库,这样就可以便于未来安装或更新软件包(通过 apt-get update 命令). ...

  10. java 偏向锁、轻量级锁及重量级锁synchronized原理

    Java对象头与Monitor java对象头是实现synchronized的锁对象的基础,synchronized使用的锁对象是存储在Java对象头里的. 对象头包含两部分:Mark Word 和 ...