今天配置下分析下nginx关于URI的部分,另外需要看下DNS的长度.简单而已,DNS长度不超过255个octets.我们是用.来分割域名的,那么每个点之间的长度不超过63个octets.
Nginx本身对于传参的长度大小支持决定于large_client_header_buffers
下面是详细分析过程.

nginx location
- 块通过指定模式来与客户端请求的URI相匹配 Sets configuration depending on a request URI.
- What's different between URI, request-URI and URL? https://stackoverflow.com/questions/34849543/whats-different-between-uri-request-uri-and-url
- What's different between URI, request-URI and URL?
- URI vs. URL
- http://nginx.org/en/docs/http/ngxhttpcore_module.html#location
nginx largeclientheader_buffers
reference:
https://www.digitalocean.com/community/tutorials/understanding-nginx-http-proxying-load-balancing-buffering-and-caching
http://nginx.org/en/docs/http/ngxhttpcoremodule.html#largeclientheaderbuffers
http://nginx.org/en/docs/http/ngxhttpproxymodule.html#proxybuffers
Our nginx.conf configure // largeclientheader_buffers 4 32k;
dump conf from running nginx process ==> As of Nginx 1.9.2 you can dump the Nginx config with the -T flag: ==> /sbin/nginx -T
-t — test the configuration file: nginx checks the configuration for correct syntax, and then tries to open files referred in the configuration.
-T — same as -t, but additionally dump configuration files to standard output (1.9.2). http { include mime.types; default_type application/octet-stream; #increase proxy buffer size proxy_buffer_size 32k; proxy_buffers 4 128k; proxy_busy_buffers_size 256k; #increase the header size to 32K large_client_header_buffers 4 32k;
- 1kb=1024 位1kB=1024 字节
Nginx
如果您的 nginx 错误日志包含 client sent too long URI while reading client request line,则表示请求 URI 已超出允许的限制。
在 nginx 中,允许的最大 URI 长度由 large_client_header_buffers 指令定义,它由两个值组成:缓冲区的数量和大小。 它默认为 4 8k,这意味着 Nginx 将每个请求行限制为 8 KB。
large_client_header_buffers 4 128K;
设置用于读取大型客户端请求标头的缓冲区的最大数量和大小。 一个请求行不能超过一个缓冲区的大小,否则会向客户端返回 414(Request-URI Too Large)错误。 请求头字段也不能超过一个缓冲区的大小,否则返回 400(Bad Request)错误给客户端。 缓冲区仅按需分配。 默认情况下,缓冲区大小等于 8K 字节。 如果在请求处理结束后连接转换为保持活动状态,则释放这些缓冲区。
设置读取客户端请求头的缓冲区大小。对于大多数请求,1K 字节的缓冲区就足够了。但是,如果请求中包含长 cookie,或者来自 WAP 客户端,则可能 1K 是不适用的。如果请求行或请求头域不适合此缓冲区,则会分配由 large_client_header_buffers 指令配置的较大缓冲区
Linux configure
- keyword for search [nginx upstream proxy length ]
- https://www.cyberciti.biz/faq/nginx-upstream-sent-too-big-header-while-reading-response-header-from-upstream/
- Use the getconf command to find os level page size value in bytes:
- getconf PAGESIZE 4096
common nginx.conf
```
gsutil cat gs://nginx/a.conf
service=name
enables resolving of DNS SRV records and sets the service name (1.9.13). In order for this parameter to work, it is necessary to specify the resolve parameter for the server and specify a hostname without a port number.
If the service name does not contain a dot (“.”), then the RFC-compliant name is constructed and the TCP protocol is added to the service prefix. For example, to look up the _http._tcp.backend.example.com SRV record, it is necessary to specify the directive:
server backend.example.com service=http resolve;
If the service name contains one or more dots, then the name is constructed by joining the service prefix and the server name. For example, to look up the _http._tcp.backend.example.com and server1.backend.example.com SRV records, it is necessary to specify the directives:
server backend.example.com service=_http._tcp resolve;
server example.com service=server1.backend resolve;
Highest-priority SRV records (records with the same lowest-number priority value) are resolved as primary servers, the rest of SRV records are resolved as backup servers. If the backup parameter is specified for the server, high-priority SRV records are resolved as backup servers, the rest of SRV records are ignored.
```
dns length
- https://en.wikipedia.org/wiki/Hostname
- Hostnames are composed of a sequence of labels concatenated with dots. For example, "en.wikipedia.org" is a hostname. Each label must be from 1 to 63 characters long.[2] The entire hostname, including the delimiting dots, has a maximum of 253 ASCII characters.[3]
- https://www.ietf.org/rfc/rfc1035.txt
- 2.3.4. Size limits Various objects and parameters in the DNS have size limits. They are listed below. Some could be easily changed, others are more fundamental. labels 63 octets or less names 255 octets or less TTL positive values of a signed 32 bit number. UDP messages 512 octets or less 1. DOMAIN NAME SPACE AND RR DEFINITIONS 3.1. Name space definitions Domain names in messages are expressed in terms of a sequence of labels. Each label is represented as a one octet length field followed by that number of octets. Since every domain name ends with the null label of the root, a domain name is terminated by a length byte of zero. The high order two bits of every length octet must be zero, and the remaining six bits of the length field limit the label to 63 octets or less. To simplify implementations, the total length of a domain name (i.e., label octets and label length octets) is restricted to 255 octets or less. Although labels can contain any 8 bit values in octets that make up a label, it is strongly recommended that labels follow the preferred syntax described elsewhere in this memo, which is compatible with existing host naming conventions. Name servers and resolvers must compare labels in a case-insensitive manner (i.e., A=a), assuming ASCII with zero parity. Non-alphabetic codes must match exactly.
- https://devblogs.microsoft.com/oldnewthing/20120412-00/?p=7873
about KB
```
首先不同编码,所占字节数不同。
1,ASCII码:一个英文字母(不分大小写)占一个字节的空间,一个中文汉字占两个字度节的空间。
2,UTF-8编码:一个英文字符等于一个字节,一个中文(含繁体)等于三个字节。中文标点占三个字节,英文标点占一个字节
3,Unicode编码:一个英文等于两个字节,一个中文(含繁体)等于两个字节。中文标点占两个字节,英文标点占两个字节
字节是指Byte
字符是一种数据类型,通常是char,更具不同语言,占据不同字节大小。
- 1kb=1024 位1kB=1024 字节
using wc :
-c, --bytes print the byte counts
-m, --chars print the character counts
]$ echo "local-stackdriver-agent.stackdriver.com"|wc -c
40
$ echo "local-stackdriver-agent.stackdriver.com"|wc -m
40
https://blog.csdn.net/weixin_48702807/article/details/120199304
getStringSize(text) {
let textlength = Buffer.byteLength(text, 'utf8'); //得到占多少 bytes
let size = textlength / 1024; //得到字符串占多少 KB
return size.toFixed(2);
},
```
spring context path limitation
- spring context path limitation
@RequestMapping(value = {REST_PREFIX + "/{key}"}, method = {RequestMethod.GET})
public DashboardItem getExceptionByKey(@PathVariable("key") String key, HttpServletRequest request, HttpServletResponse httpResponse_p) {
log.info("URL is {}", request.getRequestURL());
log.info("Key is {}", key);
return InspectionUtils.getExceptionByKey(key);
}
