Nginx反向代理的使用
一、Nginx的基本命令
- nginx:启动 nginx
- nginx -t :测试配置文件是否有语法错误
- nginx -s reopen:重启Nginx
- nginx -s reload:重新加载Nginx配置文件,然后以优雅的方式重启Nginx
- nginx -s stop:强制停止Nginx服务
- nginx -s quit:优雅地停止Nginx服务
- nginx -v或-V 显示版本信息
- nginx -c filename : 设置配置文件
二、反向代理配置
1.max_fails 和 fail_timeout说明,默认1次 和 10秒 ,一般要调整的,否则容易误判。比如max_fails设置成3
(1)fail_timeout周期内,如果失败次数达到max_fails次,那么判定节点死掉。到达fail_timeout后又会自动恢复。
如果因为连接不上节点,判断全部节点死掉,那么报错:no live upstreams while connecting to upstream 返回给浏览器502 Bad Gateway
如果因为节点响应超时,判断全部节点死掉,那么报错:no live upstreams while reading response header from upstream 返回给浏览器502 Bad Gateway
节点未判断失效 且 响应超时返回的错误编码:504 Gateway Timeout
(2)Nginx记录失效节点的可能的6种状态(time out、connect refuse、500、502、503、504),Nginx 默认connect refuse和time out状态为准,不以HTTP错误状态进行判断失败。
但是可以配置,后四项5XX需要配置在proxy_next_upstream中的状态才可以生效。
说明:time out 包括连接超时(proxy_connect_timeout 默认60秒) 和 响应超时( proxy_read_timeout 默认60秒)。
2.重试逻辑:默认错误和超时会重试,而后端响应超时不会重试。
Syntax: proxy_next_upstream error | timeout | invalid_header | http_500 | http_502 | http_503 | http_504 | http_403 | http_404 | off ...;
Default: proxy_next_upstream error timeout; 默认错误和超时会重试。
Context: http, server, location
timeout:在与服务器建立连接,向其传递请求或读取响应头时发生超时,而不是业务处理时间。
Syntax: proxy_next_upstream_tries number; 重试次数
Default: proxy_next_upstream_tries 0; 默认为0,表示不限制。
Context: http, server, location
最新文章
- 线程本地变量ThreadLocal源码解读
- easyUI增加视图分组的办法
- vb.net 控件(包括字体)随窗体按比例缩放
- golang的第一个deadlock
- IOS UIButton使用详解
- 在Mac pro上如何配置adb命令?
- Oracle左连接、右连接示例
- git 配置多个SSH-Key(转)
- [笔记]机器学习(Machine Learning) - 01.线性回归(Linear Regression)
- 201521123011《Java程序设计》第11周学习总结
- elasticsearch2.3.3安装
- Exception in thread ";main"; SettingsException[Failed to load settings from [elasticsearch.yml]]; nested: ElasticsearchParseException[malformed, expected end of settings but encountered additional conte
- 学号 20175212 《Java程序设计》第4周学习总结
- Windows与系统信息相关的DOS命令
- Decision Trees:机器学习根据大量数据,已知年龄、收入、是否上海人、私家车价格的人,预测Ta是否有真实购买上海黄浦区楼房的能力—Jason niu
- 力扣(LeetCode) 1010. 总持续时间可被 60 整除的歌曲
- DOM confirm setTimeout url刷新
- 接口测试实例(Road)
- Android给ListView添加一个入场动画
- std::time(0)找不到
热门文章
- ASP.NET Core 监听SQL Server数据库的实时信息
- PHP curl_multi_setopt函数
- PHP decoct() 函数
- PHP strripos() 函数
- 5.21 省选模拟赛 luogu P4297 [NOI2006]网络收费 树形dp
- 当asp.net core偶遇docker一(模型验证和Rabbitmq 二)
- 在龙芯mips64el平台编译bmon
- AutoUpdater迁移到Github
- C++ 内联(inline)函数
- docker,容器,编排,和基于容器的系统设计模式