nginx_keepalive
客户端配置
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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | 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 logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0;# ###################################################### keepalive_timeout 65; keepalive_timeout 65; #超过这个时间没有活动,会让keepalive失效 keepalive_time 1h; #一个tcp连接总时长,超过之后,强制失效 send_timeout 60; #默认60s,此处有坑,系统中若有耗时操作,超过send_timeout强制断开连接 #是准备过程中,不是传输过程 keepalive_requests 1000; #一个tcp复用中,可以并发接收的请求个数 ###################################################### #gzip on; upstream httpd_get { ip_hash; server 192.168.44.102; server 192.168.44.103; server 192.168.44.104; } server { listen 80; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { #正则方式 rewrite ^/[0-9].html$ /index .jsp?pageNum=$1 break ; proxy_pass http: //httpd_get ; #proxy_pass配置下 root 不生效 } location ~*/(css|js|) { root html; index index.html index.htm; } error_page 500 502 503 504 /50x .html; location = /50x .html { root html; } } } |
上游服务配置
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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | 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 logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0;# #################客户端############################### keepalive_timeout 65; keepalive_timeout 65; #超过这个时间没有活动,会让keepalive失效 keepalive_time 1h; #一个tcp连接总时长,超过之后,强制失效 send_timeout 60; #默认60s,此处有坑,系统中若有耗时操作,超过send_timeout强制断开连接 #是准备过程中,不是传输过程 keepalive_requests 1000; #一个tcp复用中,可以并发接收的请求个数 #################客户端##################################### #gzip on; upstream httpd_get { #################上游服务############################### keepalive 100; #上游服务器保证的连接数 keepalive_requests 1000; keepalive_timeout 65; #################上游服务############################### server 192.168.44.102; server 192.168.44.103; server 192.168.44.104; } server { listen 80; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { #################上游服务############################### proxy_http_version 1.1; proxy_set_header Connection "" ; #################上游服务############################### proxy_pass http: //httpd_get ; #proxy_pass配置下 root 不生效 } location ~*/(css|js|) { root html; index index.html index.htm; } error_page 500 502 503 504 /50x .html; location = /50x .html { root html; } } } |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 零经验选手,Compose 一天开发一款小游戏!
· 一起来玩mcp_server_sqlite,让AI帮你做增删改查!!