在nginx中有以下指令client_max_body_size : 设置“Content-Length”请求标题字段中指定的客户端请求主体的最大允许大小。 如果请求中的大小超过configuration的值,则413(请求实体太大)错误将返回给客户端。 正如它所说的,当在请求中提供Content-Length时使用。 我正在使用nginx作为反向代理。 不幸的是,我的nodejs为一个特定的URI实现需要一个POST正文提供Transfer-Encoding: chunked – 否则打破。 我仍然需要限制接受的身体尺寸来防止DoS。 我想让nginxclosures连接,如果太多的字节已经在正文中发送。 nginx有这个function吗? 或者,我会更好地实施nodejs服务器?
让我跳进去吧。 这是我的设置,改变了域名: upstream nodejs { server 127.0.0.1:8081; keepalive 256; } # Redirect all non-HTTPS to non-WWW HTTPS server { listen 8080; server_name "~^(?:www\.)?(.*)$"; return 301 https://$host$request_uri; } # Redirect WWW HTTP to non-WWW HTTP server { listen 4430; server_name "~^www\.(.*)$"; return 301 https://$1$request_uri; } # Reverse-proxy to http://nodejs server { listen 4430; server_name "~^(?!www\.).*$"; client_max_body_size […]
什么是每个位置使用parsing器的优点/缺点,我发现这个configuration在服务器上,但我的猜测是,它不是“重新解决”,因为proxy_pass不是也使用variables location /foo { proxy_pass http://foo_backends; resolver 10.0.0.2 valid=300s; resolver_timeout 10s; } location /bar { proxy_pass http://bar_backends; resolver 10.0.0.2 valid=300s; resolver_timeout 10s; } 从文档: 当您使用variables在proxy_pass指令中指定域名时,NGINX在TTL到期时重新parsing域名。 因此,如果我是正确的,以前的configuration可以像这样重写: resolver 10.0.0.2 valid=300s; resolver_timeout 10s; location /foo { set $foo_backend_servers foo_backends.example.com; proxy_pass http://$foo_backend_servers; } location /bar { set $bar_backend_servers bar_backends.example.com; proxy_pass http://$bar_backend_servers; } 这是正确的还是有一些技巧,每个位置使用位置? 是否可以通过使用每个位置的parsing器,不需要创build一个variables并将其传递给proxy_pass ?
我不明白为什么log_not_foundclosures不能与try_files工作。 错误“失败(2:没有这样的文件或目录)”总是保存在error_log中 没有try_files, log_not_foundclosures工作完美 我的configuration: location ~* \.(js|css|bmp|png|jpg|jpeg|gif|swf)$ { try_files $uri = 404; log_not_found off; } location ~* \.(.*)$ { try_files $uri @rewrite; } location @rewrite { rewrite ^(.*) …..; }
使用nginx作为RedHat Enterprise主机上的Web服务器。 开始认为我不完全理解nginx.conf中的位置的使用,尽pipe例子和我读过的东西。 我原本只是为了维护我们的内部维基而设置的。 我试图改变的东西,但它可以承载其他的东西。 而不是让这个wiki出现在http://myserver.corp.com 我希望这个wiki出现在http://myserver.corp.com/wiki/ / wiki不是服务器上的文件夹或存在,它应该只是将/ wiki的请求redirect到服务器上的另一个位置。 我在我的nginx.conf中更改了以下内容: server { server_name myserver.corp.com; root /var/www/public_html/; index index.html index.php; autoindex off; location /wiki { root /usr/share/mediawiki123/; } location ~ \.php$ { include fastcgi.conf; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; } } 但是,通过添加位置信息并尝试访问它,我在日志中看到以下内容: 2017/09/07 17:16:43 [错误] 614#0:* 1“/usr/share/mediawiki123/wiki/index.html”找不到(2:没有这样的文件或目录),客户端:10.13。 168.153,server:myserver.corp.com,请求:“GET / wiki / HTTP / 1.1”,主机:“myserver.corp.com” 它似乎是追加/维基到文件夹结构? 而不是试图访问:“/usr/share/mediawiki123/wiki/index.html” […]
我想将nodejs服务器的502错误redirect到维护页面。 这是我的nginxconfiguration: location /50x.html { root /var/www/html/maintenance.html; } location / { proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Proto $scheme; proxy_pass http://127.0.0.1:3000/; proxy_intercept_errors on; } error_page 500 502 503 504 /50x.html; 但没有运气,它仍然返回502 Bad Gateway 。 什么是错的,我该如何解决?
我想使用nginx作为https前端,我正在寻找一种方法来限制TCP连接。 这些限制应该基于远程IP地址,并且适用于HTTP / 1.1以及HTTP 2 。 对于HTTP / 1.1,我认为每个IP会有15个并发连接(因为大多数浏览器似乎最多使用6个),所以对于HTTP / 2应该足够了。 但是nginx文档指出: 在HTTP / 2和SPDY中,每个并发请求被认为是一个单独的连接。 HTTP / 2规范说明了SETTINGS_MAX_CONCURRENT_STREAMS参数: build议这个值不小于100,以免不必要地限制并行性。 这是否意味着我应该允许每个远程IP至less100个连接? 在我的testing中似乎是如此,但也许我错过了一些东西。 因为这个接缝本质上意味着我不能对并发TCP连接的数量设置任何有意义的限制,而不会严重限制HTTP / 2 。
我将nginx / 1.10.3与ModSecurity 3( Libmodsecurity 5f60bb5224 , ModSecurity-nginx连接器1b2860a0f1 )结合使用,并将请求代理到后端应用程序。 总体响应时间(整页加载,包括初始AJAX请求) 后端应用程序(本地):1.48秒 nginx( modsecurity off ):1.81秒 nginx( modsecurity on ):6.98秒 观察: 当直接查询后端应用程序时,会asynchronous加载资源。 当ModSecurityclosures时,资源将asynchronous加载。 当ModSecurity打开时,资源按顺序加载。 这是我的ModSecurityconfiguration。 # — Rule engine initialization ———————————————- # Enable ModSecurity, attaching it to every transaction. Use detection # only to start with, because that minimises the chances of post-installation # disruption. # […]
我真的在努力与谷歌App Engine部署我的节点JS API,因为我总是有一个502错误。 我在这个话题上看到了很多答案,但是没有一个答案对我来说。 我在日志中发现了以下错误: "[error] 32#32: *4028 connect() failed (111: Connection refused) while connecting to upstream, client: 130.211.1.248, server: , request: "GET /_ah/health HTTP/1.1", upstream: "http://172.17.0.1:8080/_ah/health" 我的想法是改变上游IP地址,目前是http://172.17.0.1:8080 ,我怎么能在Google App Engine中这样做呢? 谢谢
我有一个运行nginx 1.9.3的Ubuntu 15.10,用于提供主要是图像和video文件的静态内容。 没有其他自定义进程正在运行,甚至只占用serer资源的1%。 没有任何PHP处理,也没有任何SQL数据库连接发生。 netstat -an | wc -l的输出 netstat -an | wc -l总是在700-1500个tcp连接的范围内。 在95%的情况下,大多数用户请求下载一个3.5 MB的video文件(nginx访问日志证实这一点),由于nginx和linux本身的caching机制,我相信总是存储在RAM中。 事实上, iotop输出告诉我,大部分时间里有0 – 0.5%的磁盘读取,所以我知道我遇到的问题与磁盘I / O无关。 运行nload 3小时,告诉我,我的stream量是这样的: Curr: 103.41 MBit/s Avg: 73.97 MBit/s Min: 14.62 MBit/s Max: 457.88 MBit/s Ttl: 141357.91 GByte 每当tcp连接的数量大于1200时,用户在从服务器加载数据时会遇到延迟/超时。 让我展开一下我到目前为止所观察到的有关这些“延迟/超时”的内容: 我几乎可以肯定,nginx的configuration不是怪,因为它不只是HTTP连接,超时,但即使从另一台计算机简单地ping(ICMP)服务器时,我得到了很多“请求超时”的结果,当上面提到的TCP连接标记已到达。 当从Windows运行Wireshark并在浏览器中加载这个3.5 MB的video(在提到的高负载时),我看到很多数据包标有 [TCP ACKed unseen segment] [TCP Previous segment not captured] 这意味着这个video文件的一些块(包)没有传递给我。 […]