Nginx 413 ResultEntity Too Large 504 TimeOut

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_36324685/article/details/82701690

Nginx报错信息:


这里写图片描述

这里写图片描述

当时第一次,遇见了这两个错误,于今日整理一下,如有错误,请看客批判。

keepalive_timeout 1200;#请求超时时间 如果不好使,配置底下的参数。
fastcgi_connect_timeout 1200;
fastcgi_send_timeout 1200;
fastcgi_read_timeout 1200;

proxy_connect_timeout 300s;
proxy_send_timeout 300s;
proxy_read_timeout 300s;
client_max_body_size 50m; #主要是这个参数,限制了上传文件大大小


下面是我对nginx 的一些的学习体验:

1.我不太了解,别人的启动方式,我只知道,他应该也是个web容器,能放在自己的根目录下启动静态页面。但我不喜欢这种方式,我启动了tomcat 借他的端口启动。

2.配置文件:

*语法规则: location [=|||^~] /uri/ { … }
= 开头表示精确匹配
^~ 开头表示uri以某个常规字符串开头,理解为匹配 url路径即可。nginx不对url做编码,因此请求为/static/20%/aa,可以被规则^~ /static/ /aa匹配到(注意是空格)。
~ 开头表示区分大小写的正则匹配
~
开头表示不区分大小写的正则匹配
!和!分别为区分大小写不匹配及不区分大小写不匹配 的正则
/ 通用匹配,任何请求都会匹配到。

#user  nobody;
worker_processes 3;#启动了多少个进程

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
worker_connections  102400;
accept_mutex on;
multi_accept on; #打开同时接受多个新网络连接请求的功能。
}


http {
    server_tokens off; #隐藏版本号 在http 模块当中配置
    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  access.log  main;

    sendfile        on;
    tcp_nopush     on;

    #keepalive_timeout  0;
     keepalive_timeout  1200;#请求超时时间
	 client_max_body_size 50m;         #主要是这个参数,限制了上传文件大大小
     send_timeout 1200;
     fastcgi_connect_timeout 1200;
  fastcgi_send_timeout 1200;
  fastcgi_read_timeout 1200;
    gzip  on;
	gzip_disable "MSIE [1-6].";#压缩级别
    #设定请求缓冲
    client_header_buffer_size    128k;
    large_client_header_buffers  4 128k;
	upstream  rain { #服务器集群名字    名称则是使用的名称
	  server 127.0.0.1:8082 weight=5;#服务器配置 weight是权重的意思,权重越大,分配的概率越大。  
	  server 127.0.0.1:8084 weight=5;  	
	}	  
	  
	  
	#charset gb2312;
	
    server {
        listen       8090;
        server_name  localhost;
        error_page   500 502 503 504  /50x.html;
		#后端
		location /{
		  proxy_pass http://rain/; 
		   proxy_connect_timeout 1200s;
  		   proxy_send_timeout 1200s;
 		    proxy_read_timeout 1200s;
		}
		#配置以什么开头的
		#location ^~ /static/ {
		   #规则C
		#}
		#前端
		 location ~ .*\.(html|gif|jpg|jpeg|png|bmp|swf|js|css|ico|woff)$
        {
		   proxy_pass http://127.0.0.1:8089; 
        }
        location = /50x.html {
            root   html;
        }
    }
	
}

猜你喜欢

转载自blog.csdn.net/qq_36324685/article/details/82701690