最近在工作当中需要使用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 ...
随机推荐
- canvas画圆类似于锯齿指针 angular5
拿到图的时候大致是这样的,里面的圆是有动态效果的,考虑到gif图耗资源,于是想要用canvas画出来: 仔细看图不难发现,这个锯齿圆类似于表盘,计算好弧度,不难实现: 因为项目现在用的框架是angul ...
- Linux下不停止服务,清空nohup.out文件
转载:http://www.sucheasy.com/OracleFusionMiddleware/640.html 1.nohup.out的由来及作用 用途:LINUX命令用法,不挂断地运行命令. ...
- 拓扑排序bfs_dfs
dfs #include <cstdio> #include <cstring> using namespace std; ; struct Edge{ int lst; in ...
- Centos 安装 python2.7.10以及pip
安装python2.7.10 1. 下载安装包并解压 wget https://www.python.org/ftp/python/2.7.10/Python-2.7.10.tgz tar -xf P ...
- Python全栈之路----常用模块----time模块
time 模块的方法 time.time():返回当前时间的时间戳. >>> import time >>> time.time() #从1974年到现在过去了多少 ...
- Okhttp、Volley和Gson的简单介绍和配合使用
转载自:http://www.apkbus.com/home.php?mod=space&uid=784586&do=blog&id=61255 1.okhttp是一个高效的. ...
- 关于js的对象创建方法(简单工厂模式,构造函数模式,原型模式,混合模式,动态模式)
// 1.工厂方式创建对象:面向对象中的封装函数(内置对象) 简单来说就是封装后的代码,简单的工厂模式是很好理解的,关于它的作用,就是利用面向对象的方法,把一些对象封装,使一些占用空间多的,重复的代码 ...
- 洛谷P1019:单词接龙(DFS)
题目描述 单词接龙是一个与我们经常玩的成语接龙相类似的游戏,现在我们已知一组单词,且给定一个开头的字母,要求出以这个字母开头的最长的"龙"(每个单词都最多在"龙" ...
- Linux 文件类型笔记
在UNIX中一切都是文件https://ph7spot.com/musings/in-unix-everything-is-a-file在UNIX中,一切都是字节流 ==== linux系统的文件类型 ...
- Centos7 firewall开放3306端口
目录 Centos7 firewall开放3306端口 1. 查看防火墙状态 2. 关闭防火墙firewall 3. 关闭防火墙firewall后开启 4. 开启端口 5. 重启防火墙 6. 常用命令 ...