Nginx 错误502 upstream sent too big header while reading response header from upstream

RHEL 8 与 RHEL 7 与 RHEL 6 的比较,RHEL 8强到离谱! Red Hat Enterprise Linux(RHEL)是企业级 Linux 发行版中最受欢迎的操作系统之一。RHEL 为服务器和企业环境提供了高性能、稳定性和安全性,适用于各种数据中心和云计算平台。自 RHEL 6 以来,Red Hat 对其操作系统进行了多次重大更新,RHEL 7 和 RHEL 8 带来了许多新的特性、工具和架构变化。 阅读详情

Nginx 502 Bad Gateway的含义是请求的PHP-CGI已经执行,但是由于某种原因(一般是读取资源的问题)没有执行完毕而导致PHP-CGI进程终止。
Nginx 504 Gateway Time-out的含义是所请求的网关没有请求到,简单来说就是没有请求到可以执行的PHP-CGI。
解决这两个问题其实是需要综合思考的,一般来说Nginx 502 Bad Gateway和php-fpm.conf的设置有关,而Nginx 504 Gateway Time-out则是与nginx.conf的设置有关。
1.查看FastCGI进程是否已经启动
NGINX 502错误的含义是sock、端口没被监听造成的。我们先检查fastcgi是否在运行
2.检查系统Fastcgi进程运行情况
除了第一种情况,fastcgi进程数不够用、php执行时间长、或者是php-cgi进程死掉也可能造成nginx的502错误
运行以下命令判断是否接近FastCGI进程,如果fastcgi进程数接近配置文件中设置的数值,表明worker进程数设置太少
netstat -anpo | grep "php-cgi" | wc -l
3.FastCGI执行时间过长
根据实际情况调高以下参数值
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
4.头部太大这种情况可能是由于nginx默认的fastcgi进程响应的缓冲区太小造成的, 这将导致fastcgi进程被挂起, 如果你的fastcgi服务对这个挂起处理的不好, 那么最后就极有可能导致504 Gateway Time-out
现在的网站, 尤其某些论坛有大量的回复和很多内容的, 一个页面甚至有几百K
默认的fastcgi进程响应的缓冲区是8K, 我们可以设置大点:                                fastcgi_buffer_size 128k;
fastcgi_buffers 8 128k;
如果你使用的是nginx的负载均衡Proxying,调整
proxy_buffer_size  16k;   这里参数调大
proxy_buffers   4 16k;
5.https转发配置错误
正确的配置方法
server_name www.xok.la;
location /myproj/repos {
set $fixed_destination $http_destination;
if ( $http_destination ~* ^https(.*)$ )
{
set $fixed_destination http$1;
}
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Destination $fixed_destination;
proxy_pass http://subversion_hosts;
}
下面我们来仔细分析一下php-fpm.conf几个重要的参数:
php-fpm.conf有两个至关重要的参数,一个是”max_children”,另一个是”request_terminate_timeout”
我的两个设置的值一个是”40″,一个是”900″,但是这个值不是通用的,而是需要自己计算的。
计算的方式如下:
如果你的服务器性能足够好,且宽带资源足够充足,PHP脚本没有系循环或BUG的话你可以直接将”request_terminate_timeout” 设置成0s。0s的含义是让PHP-CGI一直执行下去而没有时间限制。而如果你做不到这一点,也就是说你的PHP-CGI可能出现某个BUG,或者你的 宽带不够充足或者其他的原因导致你的PHP-CGI能够假死那么就建议你给”request_terminate_timeout”赋一个值,这个值可以 根据你服务器的性能进行设定。一般来说性能越好你可以设置越高,20分钟-30分钟都可以。由于我的服务器PHP脚本需要长时间运行,有的可能会超过10 分钟因此我设置了900秒,这样不会导致PHP-CGI死掉而出现502 Bad gateway这个错误。
而”max_children”这个值又是怎么计算出来的呢?这个值原则上是越大越好,php-cgi的进程多了就会处理的很快,排队的请求就会很 少。设置”max_children”也需要根据服务器的性能进行设定,一般来说一台服务器正常情况下每一个php-cgi所耗费的内存在20M左右,因 此我的”max_children”我设置成40个,20M*40=800M也就是说在峰值的时候所有PHP-CGI所耗内存在800M以内,低于我的有 效内存1Gb。而如果我的”max_children”设置的较小,比如5-10个,那么php-cgi就会“很累”,处理速度也很慢,等待的时间也较 长。如果长时间没有得到处理的请求就会出现504 Gateway Time-out这个错误,而正在处理的很累的那几个php-cgi如果遇到了问题就会出现502 Bad gateway这个错误。


一个实例:
http://www.levil.cn/post/29/
我在CentOS下配置lnmp组合基本上用的都是同样的配置文件,一直都没出现过问题,可最近在一个vps上安装同样的环境之后,网站在线10多人就出 现了打开速度非常缓慢的情况,有好几次都是直接达到了nginx中设置的脚本最大超时时间300秒,结果导致nginx往客户端浏览器发送了一个504 Gateway Time-out的错误代码,分析了之后改动了几处配置文件,终于避免了该情况的出现。


从 错误代码基本可以确定跟nginx本身无关,主要是提交给php-fpm的请求未能正确反馈而导致,一般情况下,提交动态请求的时候,nginx会直接把 请求转交给php-fpm,而php-fpm再分配php-cgi进程来处理相关的请求,之后再依次返回,最后由nginx把结果反馈给客户端浏览器,但 我这个vps目前跑的是个纯php应用内容,实际上用户所有的请求都是php请求,有的耗费时间比较久,php-cgi进程就一直都被用满,而php- fpm本身的配置文件只打开了10组php-cgi进程,这样的话在线用户稍微多的话就会导致请求无法被正常处理而出错。


大概分析出了原因,下面做就比较容易了,首先是更改php-fpm的几处配置:


把max_children由之前的10改为现在的30,这样就可以保证有充足的php-cgi进程可以被使用;
把request_terminate_timeout由之前的0s改为60s,这样php-cgi进程处理脚本的超时时间就是60秒,可以防止进程都被挂起,提高利用效率。


接着再更改nginx的几个配置项,减少FastCGI的请求次数,尽量维持buffers不变:


fastcgi_buffers由 4 64k 改为 2 256k;
fastcgi_buffer_size由 64k 改为 128K;
fastcgi_busy_buffers_size 由 128K 改为 256K;
fastcgi_temp_file_write_size 由 128K 改为 256K。


好了,重新加载php-fpm和nginx的配置,再次测试,至今两周时间内没有再出现504 Gateway Time-out的情况,算是达到效果了。


另一例子:
使用ie正常.其他人用FF也正常.但是有个人使用FF浏览报错502
查看后台error日志,发现一句
upstream sent too big header while reading response header from upstream
就是反馈回来的头部信息太大
一般应该是cookie里面带的
怀疑是FF里面的某个插件引起返回太多的头部信息
一个个排查.最后发现是FireBug导致的
既然是fastcgi返回的头部太大.应该可以配置
查找资料后发现应该是和fastcgi_buffer_*有关的
将相关配置增大.发现问题解决
这边使用的是
fastcgi_buffer_size 32k;
fastcgi_buffers 8 32k;
比原来的默认4k/8k要大许多


 
http400错:
nginx的HTTP400错误,而且这个HTTP400错误并不是每次都会出现的,查了一下发现nginx 400错误是由于request header过大,通常是由于cookie中写入了较长的字符串所引起的。解决方法是不要在cookie里记录过多数据,如果实在需要的话可以考虑调整在nginx.conf中的client_header_buffer_size(默认1k)
若cookie太大,可能还需要调整large_client_header_buffers(默认4k),该参数说明如下:
请求行如果超过buffer,就会报HTTP 414错误(URI Too Long)
nginx接受最长的HTTP头部大小必须比其中一个buffer大,否则就会报400的HTTP错误(Bad Request)。


 
http413错:
在上传时nginx返回了413错误,查看log文件,显示的错误信息是:”413 Request Entity Too Large”, 于是在网上找了下“nginx 413错误”发现需要做以下设置:
在nginx.conf增加client_max_body_size的设置, 这个值默认是1m,可以增加到8m以增加提高文件大小限制;
如果运行的是php,那么还要检查php.ini,这个大小client_max_body_size要和php.ini中的如下值的最大值一致或者稍大,这样就不会因为提交数据大小不一致出现的错误。
post_max_size = 8M
upload_max_filesize = 2M


年底了事情真多,club服务器有问必答 提交页面 提交出这个问题
The page you are looking for is temporarily unavailable.Please try again later.
一看就知道是nginx的请求的错误,,惆怅啊。。
就开启了 错误日志查看。。。
tail -f error.log
就具体错误是 :
upstream sent too big header while reading response header from upstream
我们是nginx反向代理
proxy是nginx作为client转发时使用的,如果header过大,超出了默认的1k,就会引发上述的upstream sent too big header (说白了就是nginx把外部请求给后端apache ,apache返回的header  太大nginx处理不过来就导致了。
 
  server {
        listen       80;
        server_name  *.xywy.com ;
        large_client_header_buffers 4 16k;
        #charset koi8-r;
        # access_log off;
        location / {
#添加这3行 ,
                proxy_buffer_size 64k;
                proxy_buffers   32 32k;
                proxy_busy_buffers_size 128k;
           proxy_set_header Host $host;
           proxy_set_header X-Real-IP       $remote_addr;
           proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
           set $baiduspider '';
           if ( $http_user_agent ~ Baiduspider) {
              set $baiduspider Baidu;
          }
............
 
 如果是 nginx+PHPcgi 就该 
fastcgi_connect_timeout 60;
fastcgi_send_timeout 180;
fastcgi_read_timeout 180;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
fastcgi_intercept_errors on
011/01/07 11:12:57 [error] 10770#0: *38585340 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 116.22.131.154, server: *.xywy.com, request: "GET /ysmp/index.php?did=124994 HTTP/1.0", upstream: "http://127.0.0.1:8080/ysmp/index.php?did=124994", host: "xywy.yn16.com"
后来原来那错误没了出了新错误了 upstream timed out 超时?
server {
        listen       80;
        server_name  *.xywy.com ;
  large_client_header_buffers 4 16k;
        client_max_body_size 300m;
        client_body_buffer_size 128k;
        proxy_connect_timeout 600;
        proxy_read_timeout 600;
        proxy_send_timeout 600;
                proxy_buffer_size 64k;
                proxy_buffers   4 32k;
                proxy_busy_buffers_size 64k;
                proxy_temp_file_write_size 64k;
        #charset koi8-r;


        # access_log off;
后来参数我又改了下 就好了。。。
 可以参考:


http://wiki.nginx.org/NginxHttpProxyModule
http://blog.sina.com.cn/s/blog_5dc960cd0100i4mt.html


cookies的值超出了范围我是说

看看了一下日志

错误502 upstream sent too big header while reading response header from upstream

 

sudo gedit /var/log/nginx/error.log

查看错误日志

 

 

upstream sent too big header while reading response header from upstream

你去搜这个错误,网上的解释都差不多,无外乎是cookie携带的header太多了,让你设置:

fastcgi_buffer_size 128k;
fastcgi_buffers 8 128k;

逐步尝试。其中fastcgi_buffers 8 128k 这句,fastcgi_buffers 32 32k 这样更好,内存是整块分配和释放的,减少单位k数能尽可能利用。

另外,如果你用nginx做负载均衡的话,改了上述参数是没用的,要在转发的配置上,比如以下设置:

 

location @to_other {

                proxy_buffer_size  128k;

                proxy_buffers   32 32k;

                proxy_busy_buffers_size 128k;

                add_header X-Static transfer;

                proxy_redirect off;

                proxy_set_header Host $host;

                proxy_set_header X-Real-IP  $remote_addr;

                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

                proxy_pass http://backend;    #请求转发

        }

加粗的三行才会起作用。

fastcgi_* 可以理解成nginx接受client请求时的响应使用的。proxy是nginx作为client转发时使用的,如果header过大,超出了默认的1k,就会引发上述的upstream sent too big header。

可以参考:

http://wiki.nginx.org/NginxHttpProxyModule

http://blog.sina.com.cn/s/blog_5dc960cd0100i4mt.html

其它搜索结果可以无视,都是大同小异的。

 

 

 

location ~ \.php$ {

       fastcgi_buffer_size 128k;

       fastcgi_buffers 32 32k;

       include /etc/nginx/fastcgi_params;

       fastcgi_pass   127.0.0.1:9000;

       fastcgi_index index.php;

       fastcgi_param SCRIPT_FILENAME /host/web/$fastcgi_script_name;

    }



如题,最近网站频繁出现502错误,简直无法正常运转,出现这种情况大多是php-cgi超时没有返回信息,或进程僵死等情况造成的。我们的nginx已经配置到极致这些都已经老早做过修改了,但现在又出然出现。
经过分析将nginx的error log打开,发现”pstream sent too big header while reading response header from upstream”这样的错误提示,查阅了一下资料,大意是nginx缓冲区有一个bug造成的,我们网站的页面消耗占用缓冲区可能过大。参考老外写的修改办法增加了缓冲区容量大小设置,502问题彻底解决,后来系统管理员又对参数做了调整只保留了2个设置参数:client head buffer,fastcgi buffer size。

 

参考:代

http://www. sudone .com/nginx/nginx_400_bad_request.html
http://blog. rackcorp .com/?p=14

二、昨天装上nginx后在高负载的时候,论坛上传图片或者执行较长时间脚本的时候就不停的出现502 Bad Gateway ,网上搜了,大多数都是张大师的那篇解决方案,他的解决方案是

 

http 
{
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
}

 

增加了fastcgi的相应请求时间。但是我在实际中碰到了这个问题,设置到500,还是会出现,只是比我设置120的时候要少一些。后来发现主要是在一些post或者数据库操作的时候出现这种情况,静态页面是不会出现的

 

反复的查问题,调试,也加大了CGI的进程数。
务器,ip查询,手机号,proxy,天气预报,火车时刻,身份证号码,飞机航班,新华字典查询等  S6 b4 \) y& c( \! j) ]
256再加上去可能会变得很慢。占用内存大了。123cha.com1 u& }. p1 [7 b% L/ \0 \
在php-fpm.conf设置中还有一项,可能当时没注意到,无意中改了这个值。
request_terminate_timeout
这个值是max_execution_time,就是fast-cgi的执行脚本时间。
0s 123cha.com* S( v, U9 D5 q6 T; i* z6 u- R
0s为关闭,就是无限执行下去。(当时装的时候没仔细看就改了一个数字)
发现,问题解决了,执行很长时间也不会出错了。
优化fastcgi中,还可以改改这个值5s 。看看效果
终于发现502的错误其实不是nginx的问题,
php-cgi进程数不够用、php执行时间长、或者是php-cgi进程死掉,都会出现502错误

 

 

三、
一台服务器上运行着nginx php(fpm) xcache,访问量日均 300W pv左右

最近经常会出现这样的情况: php页面打开很慢,cpu使用率突然降至很低,系统负载突然升至很高,查看网卡的流量,也会发现突然降到了很低。这种情况只持续数秒钟就恢复了
检查php-fpm的日志文件发现了一些线索

 

在这几句的前面,是1000多行的关闭children和开启children的日志
原来,php-fpm有一个参数 max_requests ,该参数指明了,每个children最多处理多少个请求后便会被关闭,默认的设置是500。因为php是把请求轮询给每个children,在大流量下,每个childre到达max_requests所用的时间都差不多,这样就造成所有的children基本上在同一时间被关闭。
在这期间,nginx无法将php文件转交给php-fpm处理,所以cpu会降至很低(不用处理php,更不用执行sql),而负载会升至很高(关闭和开启children、nginx等待php-fpm),网卡流量也降至很低(nginx无法生成数据传输给客户端)) O" ], O  w$ q/ v1 X* D
解决问题很简单,增加children的数量,并且将 max_requests 设置未 0 或者一个比较大的值,重启php-fpm

 

 

四、
nginx 502错误的原因比较多,是因为在代理模式下后端服务器出现问题引起的。这些错误一般都不是nginx本身的问题,一定要从后端找原因!但nginx把这些出错都揽在自己身上了,着实让nginx的推广者备受置疑,毕竟从字眼上理解,bad gateway?不就是bad nginx吗?让不了解的人看到,会直接把责任推在nginx身上,希望nginx下一个版本会把出错提示写稍微友好一些,至少不会是现在简单的一句502 Bad Gateway,另外还不忘附上自己的大名。
502错误最通常的出现情况就是后端主机当机,当然还有。在upstream配置里有这么一项配置:proxy_next_upstream,这个配置指定了nginx在从一个后端主机取数据遇到何种错误时会转到下一个后端主机,里头写上的就是会出现502的所有情况拉,默认是error timeout,error就是当机、断线之类的,timeout就是读取堵塞超时,比较容易理解。我一般是全写上的:
proxy_next_upstream error timeout invalid_header http_500 http_503;
不过现在可能我要去掉http_500这一项了,http_500指定后端返回500错误时会转一个主机,后端的jsp出错的话,本来会打印一堆stacktrace的错误信息,现在被502取代了。但公司的程序员可不这么认为,他们认定是nginx出现了错误,我实在没空跟他们解释502的原理了……
invalid_header我也没认真查清到底指的什么,我也很想先把它弄下来
503错误就可以保留,因为后端通常是apache resin,如果apache死机就是error,但resin死机,仅仅是503,所以还是有必要保留的

 

 

 

 

昨日,有朋友问我,他将Web服务器换成Nginx 0.6.31  + PHP 4.4.7(FastCGI)后,有时候访问会出现“502 Bad Gateway”错误,如何解决。

  我让按照以下两个步骤去解决,最后在第2步中将FastCGI的timeout时间增加为300,问题解决:

  PS:比较羡慕迅雷的Web服务器,16G内存。



  1、查看当前的PHP FastCGI进程数是否够用:

netstat -anpo | grep "php-cgi" | wc -l


  如果实际使用的“FastCGI进程数”接近预设的“FastCGI进程数”,那么,说明“FastCGI进程数”不够用,需要增大。



  2、部分PHP程序的执行时间超过了Nginx的等待时间,可以适当增加nginx.conf配置文件中FastCGI的timeout时间,例如:

......
http 
{
......
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
......
}
......

TMS_WebGMaps_1.9.8.0_Full_Source TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder 立即下载

相关推荐

S32K144之芯片锁死解锁——关闭debug端口

S32K144之芯片锁死及解锁 经常捣鼓单片机就会发现,时常会因为某些操作不当导致芯片锁死情况的发生,通过Jlink我们可以读到芯片的ID,但是无法进行Debug,这很是让人苦恼。 基于S32K144的芯片锁死,一般有如下几种可能: 1、时钟配置异常,过高的配置时钟频率以及不配置时钟,都有可能造成芯片保护锁死,我就曾经因为不注意把时钟配置代码注释掉,导致芯片锁死。 2、我是微软雅黑烧写断电,如果在...

weixin_41935674的博客 1万+

nginx报错upstream sent too big header while reading response header from upstream解决方法

原文链接:https://blog.youkuaiyun.com/bzjoko/article/details/128786299。将其中的proxy_buffer_size 4k;调整到8k proxy_buffer_size 8k;从上游读取响应头时上游发送的响应头过大。授权平台用户登录后报Nginx错误。

lianlin21212411的博客 1815

从零到一:在K210上实现YOLO模型在线训练与部署全流程

本文详细介绍了在K210芯片上实现YOLO模型在线训练与部署的全流程,涵盖数据采集、模型优化、量化转换及内存管理等关键环节。通过实战案例和代码示例,帮助开发者高效利用K210的超低功耗特性与YOLO模型的实时检测能力,适用于边缘计算和物联网应用场景。

weixin_29094539的博客 350

nginx 报 upstream sent too big header while reading response header from upstream

upstream sent too big header while reading response header from upstream proxy_buffer_size 64k; proxy_buffers 32 32k; proxy_busy_buffers_size 64k;

白不懂黑的静的专栏 1万+

matlab中高频变压器怎么找,干货|手把手教你绕制高频变压器

原标题:干货|手把手教你绕制高频变压器绕制一个变压器所需材料:磁芯、骨架、各种铜线、麦拉胶带。变压器参数:磁芯:EE22原边:134T(1-3脚),辅助:32T(5-4脚),输出:15T(10-9脚)原边电感:1380±10%uH漏感:≤44uH引脚分布图: 特别注意:绕制方法为网上下载,其中变压器绕制方法是对的,但其中存在着很多问题(比如,正规变压器的绕组的头和尾是要添加铁氟龙套管的,每一层之间...

weixin_30895121的博客 2125

【2023】Java利用modbus4j实现工业设备Modbus TCP数据采集与解析

本文详细介绍了在2023年使用Java和modbus4j库实现工业设备Modbus TCP数据采集与解析的完整实践。内容涵盖开发环境搭建、TCP连接建立、开关量与模拟量数据的读取与解析、批量读取性能优化、控制指令写入以及常见错误排查指南,为开发者构建稳定高效的工业物联网数据采集系统提供全面指导。

rose2的博客 723

nginx出错:upstream sent too big header

2019独角兽企业重金招聘Python工程师标准>>> ...

weixin_33756418的博客 1312

SPI 总线信号完整性与时序一致性测试

SPI总线测试的核心目标是验证其电气与时序行为是否满足芯片规格要求,确保通信可靠性

硬核科技 330

nginx 错误502 upstream sent too big header while reading response header from upstream

查看nginx的错误日志,得到以下错误信息: upstream sent too big header while reading response header from upstream 按字面意思理解应该是upstream负载均衡的模块转发的header头超出限制值了,查看配置文件中的相关配置,并搜索相关信息。 网上同类型的错误原因,说是cookie携带的header太多了,让你设

lamp一些事儿 1万+

2026年美赛数学建模竞赛 MCM B题:使用太空电梯系统建立月球殖民地 问题一 月球殖民地材料运输的三种场景建模 详细解题思路和代码

如果运输系统不能完美工作(例如,系绳摆动、火箭失败、电梯故障等),你的解决方案在多大程度上会发生变化?技术可行性:三种方案在技术上都是可行的,但挑战不同 经济性:混合方案在长期视角下最具成本效益 时间效率:并行运输可以显著缩短总建设时间环境影响:太空电梯的环境优势明显,混合方案可平衡需求风险分散:混合方案提供了天然的风险分散机制

YOLO 617

Windows11配置WSL2支持代理上网

说起来本来这个功能我也不需要的,只是最近突然有个需求就顺便研究了下,WSL2默认的网络方式是NAT,即WSL2的网卡本身是虚拟网卡,通过以太网或WIFI的地址转换来上互联网,我试了下是不能直接走代理的,最近比较忙没具体研究,但是我用另一种方式实现了,下面介绍给需要的人。注意:这个方法只能是WIndows11系统,WIndows10系统上的WSL2缺少了一项功能导致不可用。1、方法总体没什么难度,NAT方式暂时没研究透,后续有时间再研究2、WIndows10系统不支持mirrored,暂时需要另辟蹊径。

jiexijihe945的博客 9591

[temp]Nginx 错误502 upstream sent too big header while reading response header from upstream

Nginx 502 Bad Gateway的含义是请求的PHP-CGI已经执行,但是由于某种原因(一般是读取资源的问题)没有执行完毕而导致PHP-CGI进程终止。 Nginx 504 Gateway Time-out的含义是所请求的网关没有请求到,简单来说就是没有请求到可以执行的PHP-CGI。 解决这两个问题其实是需要综合思考的,一般来说Nginx 502 Bad Gateway和php-fpm...

SURLIYA的博客 777

RT-DETR改进策略【RT-DETR和Mamba】| 替换骨干 Mamba-RT-DETR-T !!! 最新的发文热点

模块是模型中的一个重要组成部分,其主要作用是在模型的初始阶段对输入图像进行处理,方便后续的特征提取和目标检测。以下是对。

Limiiiing的博客 1322

修复Nginx 502错误:upstream sent too big header while reading response header from upstream

cookies的值超出了范围我是说 看看了一下日志 错误502 upstream sent too big header while reading response header from upstream sudo gedit /var/log/nginx/error.log 查看错误日志 upstreamsenttoobigheaderwhilereadin...

WGH100817的博客 546

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

nginx log 错误502 upstream sent too big header while reading response header from upstream

cookies的值超出了范围我是说 看看了一下日志 错误502 upstream sent too big header while reading response header from upstream   sudo gedit /var/log/nginx/error.log 查看错误日志     upstream sent too big header while rea...

weixin_34090643的博客 113

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

nginx 502错误 upstream sent too big header while reading response header from upstream

nginx 502错误 upstream sent too big header while reading response header from upstream 原本的设置是 proxy_buffer_size 4k; proxy_buffers 4 32k; proxy_busy_buffers_size 64k; 在这种配置下,使用fiddler进行抓包分析,发现只要请求的header的尺寸大于4378字节的时候就报502,当header在4377及以下的时候就正常了。 将配置更改为: p

m0_46325101的博客 705

502错误. Nginx日志:upstream sent too big header while reading response header from upstream

今天调试phalcon时发现一直502,日志里面有如下报错: 2013/10/11 23:18:44 [error] 51982#0: *1 upstream sent too big header while reading response header from upstream, client: 127.0.0.1, server: work.cc, request: "POST /ap

老鹰之歌的学习笔记 2984

nginx 502错误 upstream sent too big header while reading response header from upstream

原本的设置是 proxy_buffer_size 4k; proxy_buffers 4 32k; proxy_busy_buffers_size 64k; 在这种配置下,使用fiddler进行抓包分析,发现只要请求的header的尺寸大于4378字节的时候就报502,当header在4377及以下的时候就正常了。 将配置更改为: proxy_buffer_size 64k;...

weixin_30889885的博客 511

nginx 错误502 upstream sent too big header while reading response header from upst

原文参考:http://hi.baidu.com/wastorode/item/ec86ade6ac0af7a2c10d75f4 sudo gedit /var/log/nginx/error.log 查看错误日志 upstream sent too big header while reading response header from upstream 你去搜这个错误,网上的解释都...

追求自由自在的编程 1068

Nginx 502错误:upstream sent too big header while reading response header from upstream

原因: 在使用Shiro的rememberMe功能时,服务器返回response的header部分过大导致。 解决方法: https://stackoverflow.com/questions/23844761/upstream-sent-too-big-header-while-reading-response-header-from-upstream 转载于:https://...

an2866的博客 245
上一篇: phpstorm 快捷键
下一篇: Nginx Wiki(已过时最新:http://nginx.org/en/docs/)
烈火蜓蜻
博客等级 码龄20年 622粉丝 164原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值