最近在工作当中需要使用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
由于时在公司测试的运行,公司出于保密需要截图不允许外发,暂不将测试的截图贴上,敬请谅解!
- springboo+nginx测试反向代理02
本节对nginx配置方面会略微研究~~ 1:切换到 /opt/nginx-1.8.1/conf 目录,将nginx.conf文件拷贝到 /myprojects/nginx 目录下 2:切换到/opt/ ...
- Nginx 测试环境配置,留作笔记使用
Nginx 测试环境配置,留做笔记 以下全是配置文件的配置,如果有疑问还请移步Nginx官网参考官方文档. 环境: [root@CentOS6-M01 conf]# cat /etc/redhat-r ...
- web测试小结
今年5月份开始接触web测试,经过大半年的测试及学习,简单总结下 测试过程: 1.需求理解 2.测试策略.方案.用例编写及评审 3.测试环境搭建 4.测试执行 5.bug提单.问题跟踪 6.回归测试 ...
- 基于USB3.0的双目相机测试小结之CC1605配合CS5642 双目 500w摄像头
基于USB3.0的双目相机测试小结之CC1605配合CS5642 双目 500w摄像头 CC1605双目相机评估板可以配合使用柴草电子绝大多数摄像头应用 如:OV5640.OV5642.MT9P03 ...
- iSensor APP 之 摄像头调试 MT9D001 MT9P031 测试小结 200万像素和500万像素摄像头
iSensor APP 之 摄像头调试 MT9D001 MT9P031 测试小结 iSensor app 非常适合调试各种摄像头,已测试通过的sensor有: l OV7670.OV7725.OV ...
- 关于搭建一个高性能网站的服务器的架设思路以及nginx测试的并发
对于高性能网站的架设,主要就是请求量大,那我们该如何进行支撑? 考虑到下面的几个方面: 1.要减少请求,那对于开发人员来说,网站的css文件进行合并,背景图片也要合并,一般都是请求一张比较大的图片,然 ...
- Nginx配置小结
前两天区听了一堂Nginx的课,然后翻了一下自己之前的Nginx的笔记,做了一个简单的小结. 全局变量 $args : 这个变量等于请求行中的参数,同$query_string $content_le ...
- springboo+nginx测试负载均衡
1:之前只是用nginx调用了boot_8044这一个服务,这次新建一个boot_8055服务,并在linux上启动: 两个boot我都是放在 /myprojects 目录下的(自定义,能启动就行) ...
- Nginx 经验小结
chmod 777 永远不要 使用 777,有时候可以懒惰的解决权限问题, 但是它同样也表示你没有线索去解决权限问题,你只是在碰运气. 你应该检查整个路径的权限,并思考发生了什么事情. 把 root ...
随机推荐
- itextsharp报错PdfReader not opened with owner password
itextSharp读取Pdf时报错:PdfReader not opened with owner password 报错原因:pdf文件被用户加密了. 解决办法:在创建pdfReader实例后,加 ...
- 关于vuex和Promise reject 或.catch 的报错处理。
在我们开发过程中,经常会使用vuex来管理接口请求和返回数据. 在vue组件页面使用computed来读取vuex中state的数据. getTaskList({ commit }, payload) ...
- 剑指Offer 42. 和为S的两个数字 (其他)
题目描述 输入一个递增排序的数组和一个数字S,在数组中查找两个数,使得他们的和正好是S,如果有多对数字的和等于S,输出两个数的乘积最小的. 输出描述: 对应每个测试案例,输出两个数,小的先输出. 题目 ...
- mac搭配Nginx服务器常见问题
推流服务器主要是使用了开源的nginx和rtmp模块,网上也有很多资料,不过对有些可能出现的问题没有很好的总结. 安装brew 使用Mac进行开发很久的老司机应该对这个工具很熟悉了.brew是一个第三 ...
- jQuery获取元素上一个、下一个、父元素、子元素
jQuery.parent(expr),找父亲节点,可以传入expr进行过滤,比如$("span").parent()或者$("span").parent(&q ...
- 作用域&&闭包
在了解闭包之前,先了解作用域一,作用域简单来说就是变量和函数可以访问的范围,在es5中变量作用域一般分为全局作用域和局部作用域,这个主要依据是全局变量还是局部变量 情景1: <script> ...
- CPU瓶颈分析工具
性能指标: 一.CPU利用率. 1.用户CPU使用率:用户态CPU使用率(user)和低优先级用户态CPU使用率(nice). 2.系统CPU使用率:说明内核比较忙. 3.等待I/O的CPU使用率(i ...
- ubuntu16.04下docker安装和简单使用
前提条件 操作系统 docker-ce支持的ubuntu版本: Bionic 18.04 (LTS) Xenial 16.04 (LTS) Trusty 14.04 (LTS) 卸载旧版本docker ...
- ubuntu16.04 安装最新版nodejs
ubuntu软件仓库中自带的nodejs版本过低 $ apt-cache policy nodejs nodejs: Installed: (none) Candidate: 4.2.6~dfsg-1 ...
- Windows10关闭自动更新
1 使用windows+r调出运行,输入:services.msc2 找到Windows update,右键选择属性:将启动类型从自动改为手动.3 使用windows+r调出运行,输入:gpedit. ...