首页
Search
1
ikuai安装教程
29 阅读
2
Linux下python3运行环境快速安装教程
22 阅读
3
openresty宝塔一键安装opencc插件
20 阅读
4
使用FlareSolverr绕过cloudflare5秒盾
11 阅读
5
haproxy批量端口转发设置
5 阅读
默认分类
登录
Search
标签搜索
ikuai
vps
vpn
aliyun
腾讯云
Anaconda
python
haproxy
端口转发
nginx
openresty
opencc
go安装
ubunt
linux
debian
windows
golang
Typecho
累计撰写
8
篇文章
累计收到
0
条评论
首页
栏目
默认分类
页面
搜索到
8
篇与
的结果
2025-02-21
haproxy批量端口转发设置
安装HAProxy 如果想安装最新版则跳过懒人安装使用脚本安装yum install -y haproxy # CentOS或apt-get install -y haproxy # Ubuntu删除原来的配置文件再新建一个新的,方便快捷 /etc/haproxy/haproxy.cfg:rm -rf /etc/haproxy/haproxy.cfgvi /etc/haproxy/haproxy.cfg或者nano /etc/haproxy/haproxy.cfg#--------------------------------------------------------------------- # 全局配置 #--------------------------------------------------------------------- global log 127.0.0.1 local2 chroot /var/lib/haproxy pidfile /var/run/haproxy.pid maxconn 50000 user haproxy group haproxy daemon nbthread 4 #--------------------------------------------------------------------- # 默认配置 #--------------------------------------------------------------------- defaults mode tcp log global option dontlognull timeout connect 5000ms timeout client 50000ms timeout server 50000ms retries 3 option redispatch #--------------------------------------------------------------------- # 统计页面配置 #--------------------------------------------------------------------- listen stats bind *:9999 mode http stats enable stats uri /stats stats refresh 15s stats auth admin:admin123 stats hide-version stats show-desc "HAProxy监控统计" # 自定义页面处理 http-request return file /etc/haproxy/html/stats.html content-type "text/html" if { path / } #--------------------------------------------------------------------- # 端口转发配置 #--------------------------------------------------------------------- frontend port_range_12001_12003 bind *:12001-12003 mode tcp maxconn 20000 # ========== 合并的 stick-table(兼容旧版本语法)========== stick-table type ip size 1m expire 30s store conn_rate(10s),conn_cur,gpc0 # ========== 连接跟踪 ========== tcp-request connection track-sc0 src # ========== CC 防护规则 ========== # 定义 ACL(基于连接数和频率) acl too_many_conn sc0_conn_cur ge 5 # 并发连接数 ≥ 5 acl too_fast_conn sc0_conn_rate ge 10 # 连接速率 ≥ 10次/10秒 # 触发 CC 规则时增加计数器 tcp-request connection sc-inc-gpc0(0) if too_many_conn || too_fast_conn # 检查黑名单(gpc0 计数器 > 0) acl banned sc_get_gpc0(0) gt 0 # 拒绝非法连接 tcp-request connection reject if banned tcp-request connection reject if too_many_conn || too_fast_conn default_backend remote_servers #--------------------------------------------------------------------- # 后端服务器配置 #--------------------------------------------------------------------- backend remote_servers balance static-rr server server_12001 192.168.1.2:12001 check inter 2000 rise 2 fall 3 server server_12002 192.168.1.2:12002 check inter 2000 rise 2 fall 3 server server_12003 192.168.1.2:12003 check inter 2000 rise 2 fall 3需要注意:确保本地防火墙开放对应端口确保有足够的系统资源处理连接建议先在测试环境验证配置将监控页面改成中文显示mkdir -p /etc/haproxy/html cat > /etc/haproxy/html/stats.html << 'EOF' <!DOCTYPE html> <html> <head> <title>HAProxy监控面板</title> <meta charset="utf-8"> <style> body { font-family: Arial, sans-serif; margin: 20px; background: #f5f5f5; } .container { max-width: 1200px; margin: 0 auto; background: white; padding: 20px; border-radius: 8px; box-shadow: 0 0 10px rgba(0,0,0,0.1); } table { border-collapse: collapse; width: 100%; margin-top: 20px; } th, td { border: 1px solid #ddd; padding: 12px 8px; text-align: left; } th { background-color: #4CAF50; color: white; } tr:nth-child(even) { background-color: #f9f9f9; } .status-UP, .status-正常 { color: #4CAF50; font-weight: bold; } .status-DOWN, .status-离线 { color: #f44336; font-weight: bold; } .refresh { margin: 20px 0; } h1 { color: #333; text-align: center; margin-bottom: 30px; } button { padding: 8px 16px; background: #4CAF50; color: white; border: none; border-radius: 4px; cursor: pointer; } button:hover { background: #45a049; } </style> <script> function loadStats() { fetch('/stats;csv') .then(response => response.text()) .then(data => { const rows = data.split('\n'); const headers = rows[0].split(','); // 只显示重要的列 const importantColumns = [ 'pxname', 'svname', 'scur', 'smax', 'stot', 'status', 'check_status', 'lastchg', 'check_desc' ]; // 中文表头映射 const headerMap = { 'pxname': '代理名称', 'svname': '服务器名称', 'scur': '当前连接数', 'smax': '最大连接数', 'stot': '总连接数', 'status': '状态', 'check_status': '检查状态', 'lastchg': '最后变更(秒)', 'check_desc': '检查描述' }; // 创建表头 let html = '<table><tr>'; importantColumns.forEach(col => { const colIndex = headers.indexOf(col); if (colIndex !== -1) { html += `<th>${headerMap[col] || col}</th>`; } }); html += '</tr>'; // 添加数据行 for(let i = 1; i < rows.length; i++) { if(rows[i].trim() === '') continue; const cols = rows[i].split(','); html += '<tr>'; importantColumns.forEach(col => { const colIndex = headers.indexOf(col); if (colIndex !== -1) { let value = cols[colIndex]; if(col === 'status') { const statusClass = value === 'UP' ? 'status-UP' : 'status-DOWN'; value = value === 'UP' ? '正常' : '离线'; html += `<td class="${statusClass}">${value}</td>`; } else if(col === 'lastchg') { // 转换秒数为可读格式 const seconds = parseInt(value); const minutes = Math.floor(seconds / 60); const hours = Math.floor(minutes / 60); const days = Math.floor(hours / 24); if(days > 0) { html += `<td>${days}天</td>`; } else if(hours > 0) { html += `<td>${hours}小时</td>`; } else if(minutes > 0) { html += `<td>${minutes}分钟</td>`; } else { html += `<td>${seconds}秒</td>`; } } else { html += `<td>${value}</td>`; } } }); html += '</tr>'; } html += '</table>'; document.getElementById('stats').innerHTML = html; }); } // 每5秒刷新一次 setInterval(loadStats, 5000); loadStats(); </script> </head> <body> <div class="container"> <h1>HAProxy监控面板</h1> <div class="refresh"> <button onclick="loadStats()">刷新数据</button> <span>(每5秒自动刷新)</span> </div> <div id="stats"></div> </div> </body> </html> EOF启动服务systemctl start haproxy创建一个简单的管理脚本(方便操作):#!/bin/bash # 保存为 haproxy-manage.sh CONFIG_FILE="/etc/haproxy/haproxy.cfg" # 检查配置 check_config() { haproxy -c -f $CONFIG_FILE } # 重载配置 reload_config() { systemctl reload haproxy } case "$1" in "check") check_config ;; "reload") check_config && reload_config ;; "status") systemctl status haproxy ;; *) echo "使用方法: $0 {check|reload|status}" ;; esac给脚本执行权限chmod +x haproxy-manage.sh检查配置./haproxy-manage.sh check重载配置(不影响现有连接)./haproxy-manage.sh reload查看状态./haproxy-manage.sh status
2025年02月21日
5 阅读
0 评论
0 点赞
2025-01-12
Linux下python3运行环境快速安装教程
在安装 Anaconda(python环境) 时,可以通过以下方法跳过阅读协议并快速完成安装: 避免安装python的步骤繁琐,使用Anaconda一键安装先下载Anacondawget -O Anaconda3.sh https://repo.anaconda.com/archive/Anaconda3-2024.10-1-Linux-x86_64.sh方法 1:自动接受协议 运行安装脚本时,使用 -b 参数(表示批量模式)可以跳过阅读协议并自动接受:bash Anaconda3.sh -b• -b 选项会默认接受所有提示,包括协议和安装路径。 • 安装完成后,Anaconda 将默认安装到你的用户主目录下的 ~/anaconda3。方法 2:提前指定安装路径 如果还想自定义安装路径,可以使用 -p 参数指定路径:bash Anaconda3.sh -b -p ~/my_anaconda这会将 Anaconda 安装到 ~/my_anaconda 目录下。方法 3:静默模式(最简洁) 通过 yes 命令自动接受协议:yes | bash Anaconda3.sh此方法模拟手动连续按回车键,跳过协议阅读部分。完成安装后操作: 添加 Anaconda 到环境变量:echo 'export PATH=~/anaconda3/bin:$PATH' >> ~/.bashrc source ~/.bashrc验证安装:conda --version
2025年01月12日
22 阅读
0 评论
0 点赞
2025-01-11
ikuai安装教程
两种安装方式 阿里云 腾讯云 推荐第二种第一种方法:下载iKuai8_3.3.3(32位)命令:wget -O ikuai.iso https://www.ikuai8.com/download.php?n=/3.x/iso/iKuai8_x32_3.3.3_Build202002040918.isoiKuai8_3.3.3(64位)命令:wget -O ikuai.iso https://www.ikuai8.com/download.php?n=/3.x/iso/iKuai8_x64_3.3.3_Build202002040918.iso下载完成后重启服务器 在引导页面按C 进入GRUB模式,如果来不及按跳到原系统修改等待时间nano /etc/default/grub将等待时间设置30秒GRUB_TIMEOUT=30保存文件后,运行以下命令更新 GRUB:然后重启系统重新在引导页面按C 进入GRUB模式在GRUB模式输入以下代码有的支持粘贴:loopback loop /root/ikuai.iso linux (loop)/boot/vmlinuz bootguide=cd initrd (loop)/boot/rootfs bash boot阿里腾讯的机器不需要手动设置IP 只要在ikuai控制台 将eth0的网卡设置为wan1即可最后别忘了输入o选项 再输入2 开启外网访问,默认端口80第二种方法:步骤1: 下载ISO安装包x32位wget https://www.ikuai8.com/download.php?n=/3.x/iso/iKuai8_x32_3.5.11_Build202112031159.iso -O ikuai8.isox64位wget https://www.ikuai8.com/download.php?n=/3.x/iso/iKuai8_x64_3.5.11_Build202112031159.iso -O ikuai8.iso步骤2: 挂载ISO镜像mount ikuai8.iso /mnt步骤3: 复制ISO镜像启动文件cp -rpf /mnt/boot /步骤4: reboot重启步骤5: 在腾讯云/阿里云的操作页面打开VNC界面: 登录/远程登录 --> VNC登录,正常ISO安装爱快系统步骤6: 进入控制台输入1 进入网卡绑定 删除默认的lan1del lan1再绑定外网网卡set wan1 eth0"开启外网访问WEB"o、其他选项 --> 2、开启外网访问web
2025年01月11日
29 阅读
0 评论
0 点赞
1
2