Set a Timeout in Spring 5 Webflux WebClient

  • idle timeout: 闲置 超时时间
  • Response Timeout
    The response timeout is the time we wait to receive a response after sending a request.
  • connection timeout:
    The connection timeout is a period within which a connection between a client and a server must be established.
  • read & write timeout:
    A read timeout occurs when no data was read within a certain period of time, while the write timeout when a write operation cannot finish at a specific time.
阅读更多

使用logrotate工具实现nginx日志切割

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/usr/local/nginx/logs/*.log {
# 指定转储周期为每天
daily
# 使用当期日期作为命名格式
dateext
# 如果日志丢失,不报错继续滚动下一个日志
missingok
# 保留 31 个备份
rotate 31
# 不压缩
nocompress
# 整个日志组运行一次的脚本
sharedscripts
# 转储以后需要执行的命令
postrotate
# 重新打开日志文件
[ ! -f /usr/local/nginx/nginx.pid ] || kill -USR1 `cat /usr/local/nginx/nginx.pid`
endscript
}
阅读更多

nginx conf if

nginx支持if语法,语法和平常的代码格式差不多:

1
2
3
4
5
6
   if ($http_x_user = "summer") {
return 401;
}
if ($remote_addr = "192.168.2.2") {
return 401;
}

只是和代码不同的是,if条件语句判断相等只要一个等号,不是==。

nginx虽然有if,但是却不支持else,如果想要构造else语法,可以使用下面的这个“小诀窍”:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
server {
server_name *.maqian.io;
listen 80;

location / {
set $is_matched 0;
if ($host = a.maqian.io) {
proxy_pass https://127.0.0.1:1001/;
set $is_matched 1;
}

if ($host = b.maqian.io) {
proxy_pass https://127.0.0.1:1002/;
set $is_matched 1;
}
# 没有匹配到,跳转到默认页面
if ($is_matched = 0) {
proxy_pass https://127.0.0.1;
}

# xxx
# xxx
# xxx
}
}

参考文章

https://docs.nginx.com/nginx/admin-guide/load-balancer/using-proxy-protocol/
https://nginx.org/en/docs/http/ngx_http_core_module.html?&_ga=2.71427731.14852861.1651803177-1904749950.1651803177#var_proxy_protocol_addr

nginx -s reload

nginx -s reload acts :

  • nginx master process running (not restarted)
  • nginx worker process restarted
阅读更多

Kafka 总结

请说明什么是Apache Kafka?

Apache Kafka是由Apache开发的一种发布订阅消息系统,它是一个分布式的、分区的和重复的日志服务

阅读更多