详解:502 Bad Gateway nginx/xxx
来源:互联网 发布:网络录像机添加摄像头 编辑:程序博客网 时间:2024/06/13 05:04
我们访问网站时,偶尔可能会遇到这样的错误:502 Bad Gateway nginx/xxx
刷新一次或多次就好了。这是什么原因呢?
最近使用nginx的代理、负载均衡功能发现了这问题的根本原因。
什么原因?就是后端的服务挂了!
示例配置一:
server{ listen 80; resolver 8.8.8.8; #server_name localhost; location / { proxy_pass http://192.168.1.210:80809$request_uri; proxy_set_header Host $http_host; #proxy_buffers 256 4k; #proxy_max_temp_file_size 0k; proxy_redirect off; proxy_http_version 1.1; proxy_set_header X-Real-IP $remote_addr; #proxy_set_header X-Forwarded-For$proxy_add_x_forwarded_for; #proxy_set_header Upgrade $http_upgrade; #proxy_set_header Connection "upgrade"; } }这种情况如果后端的服务挂了,那你怎么刷都 是没有用的,除非后端的服务恢复了。
示例配置二:
upstream backtomcat { server 192.168.1.210:7080; server 192.168.1.211:8980; server 192.168.1.212:8980;server 192.168.1.213:8980; }
server{listen 80;resolver 8.8.8.8;#server_name localhost;location / {proxy_pass http://backtomcat$request_uri;proxy_set_header Host $http_host;#proxy_buffers 256 4k;#proxy_max_temp_file_size 0k;proxy_redirect off;proxy_http_version 1.1;proxy_set_header X-Real-IP $remote_addr; } }这种情况就是使用了负载均衡,后端有N+1台服务器,你每次访问时虽然页面是一样的,但访问的后端服务器可能不 是一个,这种情况通过刷新是可以解决问题的。
当然,这两种情况都只是Nginx的简单配置应用,没有判断后端是否可用,如果添加的判断后端是否可用的配置,是根本看不到这个错误的。
===========文档信息============
版权声明:非商用自由转载-保持署名-注明出处
署名(BY) :testcs_dn(微wx笑)
文章出处:[无知人生,记录点滴](http://blog.csdn.net/testcs_dn)
2 0
- 详解:502 Bad Gateway nginx/xxx
- nginx 502 bad gateway
- nginx 502 Bad Gateway
- 502 Bad Gateway nginx
- nginx 502 bad gateway
- nginx 502 bad gateway
- 解决nginx 502 bad gateway
- Homestead nginx 502 Bad Gateway
- nginx 502 Bad Gateway 错误问题收集
- nginx 502 Bad Gateway 错误问题收集
- nginx 502 Bad Gateway 错误问题收集
- nginx 502 Bad Gateway 错误解决办法
- Nginx 502 Bad Gateway错误的解决办法
- nginx 502 Bad Gateway 错误问题收集
- flask uwsgi nginx 出现502 Bad Gateway
- 配置nginx报502 bad gateway
- nginx 502 Bad Gateway 错误问题收集
- nginx 502 Bad Gateway 错误解决办法
- 2084 杭电 数塔【简单dp】
- Android实现https网络通信之添加指定信任证书/信任所有证书
- IJKPlayer使用MediaCodec解码和渲染视频过程分析
- iOS NSNotification的使用
- 简单c-3
- 详解:502 Bad Gateway nginx/xxx
- [转]如何手动启用/禁用磁盘写入缓存
- str家族
- ubuntu 安装java jdk 全套教程
- 49骰子数独(13)115(14)
- OrientDB 图状数据库示例
- 检查虚拟机是否使用virtio
- spring容器加载完毕做一件事情(利用ContextRefreshedEvent事件)
- 微信小程序带来的颠覆