haproxy-wi 一款国外的HAPROXY面板管理工具 在线配置修改【2020踩坑记录】
Table of Contents
安装旧版本:
新版V4.5运行后遇到的问题:
手动安装原文
新版V4.5部署过程遇到的问题:
新增被管理的主机节点
The "Credentials" description
面板设置中配置HAPROXY对应的参数
HAProxy config配置,官方说明
小结:
作者github:https://github.com/Aidaho12/haproxy-wi
官方安装文档:https://haproxy-wi.org/installation.py#manual
官方提供rpm和docker两种安装方式,然而需要按月选择不同套餐来“捐赠”获得账号密码,进行在线下载安装。
关于haproxy-wi在国内的相关教程或者经验并不多……看起来是个管理HAPROXY不错的面板……
很久以前是提供脚本安装的,类似(
sudo git clone https://github.com/Aidaho12/haproxy-wi.git /var/www/haproxy-wi
导航到/var/www/haproxy-wi并运行安装程序:
cd /var/www/haproxy-wi
chmod +x install.sh
sudo ./install.sh
在运行脚本时,系统会要求你选择要使用的数据库并设置其他变量:
);
安装旧版本:
通过Github分支找到带安装脚本的老版本:
别人克隆的:https://github.com/aiminickwong/haproxy-wi
安装方法,参考当时网上留下的教程:https://ywnz.com/linuxyffq/4648.html
使用误区
不同分组的setting,如haproxy的相关setting是可以分开设置的,先建立group,然后去新增对应的用户,然后用该用户登录操作。
新版V4.5运行后遇到的问题:
1、登录后又回到登录界面
/etc/httpd/conf.d/haproxy-wi.conf
在端口80并关闭ssl engine时发生了该情况
2、配置对应的server,SSH登录或账号密码登录正确,但是error:timed out
因为安装了Fail2ban组件,在官方操作手册中启动了,估计需要进一步配置不然被ban,我们先关掉systemctl stop fail2ban,Fail2Ban是一种入侵防御软件框架,可以保护计算机服务器免受暴力攻击。它使用Python编程语言编写,能够在POSIX系统上运行,该系统具有与本地安装的数据包控制系统或防火墙的接口,例如iptables或TCP Wrapper
https://haproxy-wi.org/services.py?service=fail2ban#fail2ban
3、SSH公钥要自己先在服务器上配,面板上配密码,或者按报错信息去手动touch一个文件.pem(注意赋权,没有权限才需要手动,有权限update自动生成了)
好像不能使用带密码验证的KEY,使用不带密码的KEY可以访问,开启公钥时Credentials填写用户名
4、看不了配置可能的原因,看报错/var/log/httpd/haproxy-wi.error.log
[Fri Sep 18 16:29:03.600587 2020] [cgi:error] [pid 25683] [client 218.70.86.178:21345] AH01215: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe7 in position 2522: ordinal not in range(128): /var/www/haproxy-wi/app/options.py, referer: https://www.X.com/app/config.py?service=haproxy&serv=47.101.221.7&showConfig
检查了环境、python、代码等,没有异常,在centos7环境下配置文件中遇到中文会出现以上报错,2522是对应haproxy.cfg配置的字符位置,仔细看报错可以很快定位原因。
centos8环境下:安装完运行中看日志缺少paramiko,再安装pip3 install paramiko -i https://pypi.tuna.tsinghua.edu.cn/simple
可以正常显示、编辑配置,并且配置中的中文没有异常。
更深入的原因还是centos7、python3.x环境下unicode报错相关(但是该配置文件中也没有必要用中文,就不要探究编码问题了,记住请勿用中文去注释内容就行了,毕竟作者也不会考虑到中文啊)
可以看配置的时候,Last edit、Map、Open都是可以使用的。
5、编辑配置文件报错
Some errors:
sudo: hapee-2.0-lb: command not found
centos7下遇到该问题,没有该组件/命令,简单找了下yum没看到,百度没有,谷谷查了下跟haproxy企业版有关?
centos8下可以正常编辑。
同时看后台报错
[Mon Sep 21 01:23:18.595506 2020] [cgi:error] [pid 25146] [client x:30982] AH01215: dos2unix: converting file /var/www/haproxy-wi/configs/hap_config/47.101.221.7-2020-09-20.17:23:18.cfg to Unix format ...: /var/www/haproxy-wi/app/config.py, referer: https://x.cn/app/config.py?service=haproxy&serv=47.101.221.7&open=open
难道跟编码又有关系?……如果这样还是用centos8吧。
小结:按理编辑配置文件保存不涉及版本问题,不涉及需要haproxy调用的命令,但除了centos7/8版本不一样,还有可能的是HAPROXY的版本问题,因为我默认centos8装的HAPROXY版本会高一些,可以在centos7下再装高版本试下。
小结:centos8下无论docker还是实例环境,有中文等情况下,打开配置、保存配置都正常,尚不清楚centos7下不能打开包含中文等字符的原因,由哪些组件决定。不然调整后centos7下也应该支持的。
6、某次docker内centos7,使用其他https端口功能都验证成功了:
小结:用443端口有问题,80端口也有其他问题表现,自定义了https的8085端口,访问功能都正常了。
部分配置如下
ssl.conf
Listen 8085 https
<VirtualHost _default_:8085>
haproxy-wi.conf
<VirtualHost *:8085>
SSLEngine on
ServerName localhost:8085
7、BUG:SSH名单,新增一项后,会自动在你名字后面加_All,如果你立即编辑下方的upload,选项仍然是没有包含_All的,此时如果你提交就和之前的名单无关。需要回车浏览器地址,进行硬刷新,upload名单里面就显示出来带_All的项了。此时更新就是有效的、对应的。
手动安装原文
(网站可以打开,但是以下代码在官网可能需要翻翻才能看到,可能调用了被拦截的引用代码模块):
Manual(docker用问题不大,主要是几个启动方法需要琢磨下,不能用service和systemctl,在原文基础上补充了绝对路径以及去掉了sudo)
cd /var/www/
git clone https://github.com/Aidaho12/haproxy-wi.git /var/www/haproxy-wiCentOS 7:yum install https://repo.ius.io/ius-release-el7.rpm epel-release
yum -y install git nmap-ncat net-tools dos2unix python3 python3-pip \
python36-ldap3 python36-pytz python36-requests python36-future \
python36-jinja2 python36-bottle python-configparser \
httpd mod_ssl rsync ansible我自己改的版本:
yum -y install git nmap-ncat net-tools dos2unix python3 python3-pip \
python36-ldap3 python36-pytz python36-requests python36-future \
python36-jinja2 python36-bottle python-configparser \
httpd httpd24u-mod_ssl.x86_64 rsync ansiblepip3 install -r /var/www/haproxy-wi/config_other/requirements_el7.txtCentOS 8:yum -y install python36 python3-pip python36-devel dos2unix httpd mod_ssl \
nmap-ncat net-tools lshw python3-ldap rsync ansible python3-jinja2
pip3 install -r /var/www/haproxy-wi/config_other/requirements_el8.txt
#pip加这个指定清华源,-i https://pypi.tuna.tsinghua.edu.cn/simple
pip3 install paramiko -i https://pypi.tuna.tsinghua.edu.cn/simple
#再补充安装paramiko,不知道为什么没有包含,不然看不了配置文件Both CentOS:cp /var/www/haproxy-wi/config_other/httpd/* /etc/httpd/conf.d/Or if you use Debian/Ubuntu:sudo apt-get install git net-tools lshw dos2unix apache2 \
python3-pip g++ freetype2-demos libatlas-base-dev apache2-ssl-dev netcat python3 \
python3-ldap libpq-dev python-dev libpython-dev libxml2-dev libxslt1-dev libldap2-dev \
libsasl2-dev libffi-dev python3-dev libssl-dev gcc rsync ansible \
libpng-dev libqhull-dev libfreetype6-dev libagg-dev pkg-config -y
chown -R www-data:www-data haproxy-wi/
sudo cp haproxy-wi/config_other/httpd/* /etc/httpd/available-sites/
sudo a2ensite haproxy-wi.conf
sudo a2enmod cgid
sudo a2enmod ssl
pip3 install -r /var/www/haproxy-wi/requirements.txtBothchmod +x /var/www/haproxy-wi/app/*.py
chmod +x /var/www/haproxy-wi/app/tools/*.py
cp /var/www/haproxy-wi/config_other/logrotate/* /etc/logrotate.d/
cp /var/www/haproxy-wi/config_other/syslog/* /etc/rsyslog.d/
cp /var/www/haproxy-wi/config_other/systemd/* /etc/systemd/system/
systemctl daemon-reload
systemctl restart httpd
systemctl restart rsyslog
systemctl restart metrics_haproxy.service
systemctl restart keep_alive.service
systemctl enable metrics_haproxy.service
systemctl enable keep_alive.service
mkdir /var/www/haproxy-wi/app/certs
mkdir /var/www/haproxy-wi/keys
mkdir /var/www/haproxy-wi/configs/
mkdir /var/www/haproxy-wi/configs/hap_config/
mkdir /var/www/haproxy-wi/configs/kp_config/
mkdir /var/www/haproxy-wi/configs/nginx_config/
mkdir /var/www/haproxy-wi/log/
chown -R apache:apache /var/www/haproxy-wi/
Ansible install(我没用)
mkdir /usr/share/httpd/.ansible
touch /usr/share/httpd/.ansible_galaxy
mkdir /usr/share/httpd/.ssh
chown apache:apache /usr/share/httpd/.*
echo "apache ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoersOr if use Debian/Ubuntu:mkdir /usr/share/apache2/.ansible
touch /usr/share/apache2/.ansible_galaxy
mkdir /usr/share/apache2/.ssh
chown apache:apache /usr/share/httpd/.*
echo "www-data ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
SELinux policy Installing(普通repo没有该组件,没有安装,可能也就是部分端口放通的一些策略,避免关防火墙,一般对我们不适用)
yum install haproxy-wi-selinux
Fail2ban Installing(没有配置好,可能会因为该安全组件拦截部分端口)
For EL:
yum install fail2banFor Debian/Ubuntu:
apt-get install fail2banAfter installation you should copy config files:cp /var/www/haproxy-wi/config_other/fail2ban/filter.d/* /etc/fail2ban/filter.d/
cp /var/www/haproxy-wi/config_other/fail2ban/jail.d/* /etc/fail2ban/jail.d/Enable and start the services:systemctl start fail2ban
systemctl enable fail2ban
新版V4.5部署过程遇到的问题:
1、ssl要求httpd版本需大于2.4.6-93,但是centos7部分repo没有该版本,手动进行RPM安装。
http://rpmfind.net/linux/RPM/centos/7.8.2003/x86_64/Packages/httpd-2.4.6-93.el7.centos.x86_64.html
rpm -ivh httpd-2.4.6-93.el7.centos.x86_64.rpm
2、默认是https访问,httpd配置在/etc/httpd/conf.d/下,之前命令中将配置文件复制到了该目录下。
chown -R apache:apache /var/www/haproxy-wi/
这一步非常重要,不然访问了页面跳转后是空白,一些py页面,因为httpd没有访问权限,
包括后面的秘钥文件,也要chown apache.apache,不然在线update不了。(给上级目录-R全部赋权下来,密钥update会自动创建)
面板默认登录账号密码admin/admin
新增被管理的主机节点
该面板管理主机的思路是该面板直连需要管理主机的22端口,通过账号密码或者SSH KEYS连接。
秘钥保存路径:/var/www/haproxy-wi/keys
文件名(注意权限):hostname_All.pem
然后可以在平台上在线安装haproxy等组件,管理等等。
在页面上可以在线upload ssh keys,仅是替换文本里面的内容,没有检验、转换,改错了认不了,要自己查秘钥内容对不对。
Credentials是ssh user name
How to set up servers you can watch in this video:
Note: if SSH user use sudo, sudo must be with option: NOPASSWD
具体视频不捐赠是看不了的……
The "Credentials" description
Parameter: | Description: |
Name: | It's just name alias. This alias will be used in 'Servers' page for choose credentials |
SSH key | If it is enabled, the key will be used, if turned off - the password. Do not forget to download the key to all servers and if SSH user use sudo, sudo must be with option: NOPASSWD |
Group | You can set one of the exists group. Group = namespace. Members from one group cannot see servers from another |
Credentials | You can set username and password(if SSH key is disabled) for access by SSH. If SSH user use sudo, sudo must be with option: NOPASSWD |
Upload SSH Key | Choose exists credential name for uploading SSH key |
Key | Private key. Note: The public key must be pre-installed on all servers to which you plan to connect |
关于httpd相关配置的设置Apache settings
If you want to use your own Domain name you should edit haproxy-wi.conf for Apache:
sudo vi /etc/httpd/conf.d/haproxy-wi.conf
Edit the next string, replace "haprox-wi.example.com" on your own:
<VirtualHost my_domain.local:80>
ServerName my_domain.local
Redirect permanent / https://my_domain.local</VirtualHost>
And if you want to have redirect from the port 80 to the port 443, you should add next:
<VirtualHost my_domain.local:443>
...
ServerName my_domain.local
...
</VirtualHost>
In order to change the certificates you should edit:
<VirtualHost my_domain.local:443>
...
SSLEngine on
SSLCertificateFile /var/www/haproxy-wi/app/certs/haproxy-wi.crt
SSLCertificateKeyFile /var/www/haproxy-wi/app/certs/haproxy-wi.key
...
</VirtualHost>
面板设置中配置HAPROXY对应的参数
还需要在Admin areas -Groups-Servers-Setting里设置HA相关的配置,不然怎么找到你对应的HA呢?
最后三条可能需要进一步设置(在haproxy.cfg中进行对应的配置)
思考:如果有很多haproxy节点,面板参数不一样的话,可能没法管理?毕竟这一个haproxy参数管控所有新增的节点,那么被管控的haproxy节点需要所有以下参数一致。
测试,start,stop,restart有效,reload待测,restart如果之前不是用面板启动的可能杀不了,导致同时启动多个HA,进默认面板刷新能随机刷出同时存在的不同pid的HA。
还没配socket相关,ha原本管理面板的配置完成,可以在stat里看以下内容,这个应该是调用默认面板的内容。
如果未使用面板自带安装的HA,Runtime API, Metrics and Alerting相关功能需要进一步设置, enable state file and stat socket on the HAProxy servers and needs install socat to the all haproxy servers, and configre the HAProxy:
HAProxy config配置,官方说明
If you use installed HAProxy without HAProxy-WI then for Runtime API, Metrics and Alerting enable state file and stat socket on the HAProxy servers and needs install socat to the all haproxy servers, and configre the HAProxy:
global
stats socket *:1999 level admin
stats socket /var/run/haproxy.sock mode 600 level admin
server-state-file /etc/haproxy/haproxy.statedefaults
load-server-state-from-file globallisten stats
bind *:8085
stats enable
stats uri /stats
stats realm HAProxy-04\ Statistics
stats auth admin:password
stats admin if TRUE
[ALERT] 259/165843 (2554) : parsing [/etc/haproxy/haproxy.cfg:28] : unknown keyword 'server-state-file' in 'global' section
[ALERT] 259/165843 (2554) : parsing [/etc/haproxy/haproxy.cfg:55] : unknown keyword 'load-server-state-from-file' in 'defaults' section
以上两个配置无效,可能是版本原因。
For Antibot protection add the next two backends:
对于反机器人保护,添加以下两个后端:
backend per_ip_and_url_rates
stick-table type binary len 8 size 1m expire 24h store http_req_rate(24h)backend per_ip_rates
stick-table type ip size 1m expire 24h store gpc0,gpc0_rate(30s)
小结:
本面板实现修改haproxy.cfg的思路
py网页,通过账号密码或SSH keys连22端口,获取配置文件,分段、行数显示出来,在线编辑保存。
网上也有几个老男孩的服务器上的py脚本来管理haproxy配置文件。
haproxy-wi 一款国外的HAPROXY面板管理工具 在线配置修改【2020踩坑记录】相关推荐
- 10款国外免费网站在线监控服务工具
我们任何人不能保证自己能够24小时在电脑前,即便我们有选择高富帅VPS主机产品也不能100%的确保不出现任何问题,有些时候可能是服务商机器稳定性问题,也有的时候是我们自身网站出现问题导致VPS主机的宕 ...
- ECS 7天实践训练营day5-安装Linux服务器面板管理工具
ECS 7天实践训练营day5-安装Linux服务器面板管理工具 Linux的服务器连接之后是命令行界面,不便于使用.这次我们安装宝塔面板,来增加易用性. 一.使用butty工具连接服务器 打开but ...
- day5 安装Linux服务器面板管理工具
day5 安装Linux服务器面板管理工具 宝塔面板的安装 宝塔:下载链接 安装软件 Apache:Web服务器软件 MySQL:数据库 PHP:动态网页 修改用户及密码 阿里云链接 阿里云高校计划, ...
- 五款轻量型bug管理工具横向测评
最近正在使用的本地bug管理软件又出问题了,已经记不清这是第几次了,每次出现问题都要耗费大量的时间精力去网上寻找解决方案,劳心劳力.为了避免再次出现这样的情况,我决定从线下转到线上,使用轻量型的在线b ...
- IconJar - Mac 上的一款多功能图标素材管理工具
IconJar - Mac 上的一款多功能图标素材管理工具 IconJar 是一个多功能的图标管理工具,由世界各地的设计师和开发人员使用.在一个应用程序中搜索.组织.预览和检索图标,而不是创建大量的文 ...
- 管理多个微信群,为什么说选择一款好用的社群管理工具很重要?
什么是社群管理工具?简单来说就是为了辅助处理微信群内一些简单.繁杂的工作内容.复杂点来说就是通过一堆程序来完成社群日常维护工作的各种应用场景:自动发送入群欢迎语.自动回复.管理群员.多群群发等等.所以 ...
- AI 工具分享第 4 期:13 款国外免费AI视频生成工具
0. 未来百科 未来百科,是一个知名的AI产品导航网站 -- 为发现全球优质AI工具而生 .目前已 聚集全球3000+优质AI工具产品 ,旨在帮助用户发现全球最好的AI工具,同时为研发AI垂直应用的创 ...
- 五款最佳VMware vSphere免费管理工具
http://virtual.51cto.com/art/201407/444416.htm 东西的价值和价钱相关的理论并不适用于所有情况,特别是当你在选择VMware vSphere管理工具时.对于 ...
- 一款高颜值开源知识管理工具
[公众号回复 "1024",免费领取程序员赚钱实操经验] 大家好,我是章鱼猫. 今天推荐的这个项目是「think」,云策文档,一款开源知识管理工具,通过独立的知识库空间,结构化地组 ...
最新文章
- pytorch使用 torchvision 的 Transform 读取图片数据
- vue中使用markdown富文本,并在html页面中展示
- 图解CSS3----5-否定伪类选择器
- primeNG DataTable中Templating ng-template标签报错
- 解决win2003不支持FLV播放的方法
- 各种排序算法的分析及javapython实现
- 远程线程需要注意的问题
- 设计软件哪里找?图片素材哪里找?
- Flash/Flex学习笔记(34):AS3中的自定义事件
- 通过创建一个位图的XY Chart来学习Android绘图类Rect,Paint,Bitmap,Canvas(附源码)
- Java原生http请求调用企业微信api,获取打卡记录
- 西门子触摸屏程序锁屏V1.0
- Java 实训1:编写一个窗体程序显示日历表。
- windows 7 多国语言包官方下载资源共享(32/64位)
- 0xC0000005: 读取位置 xxx时发生访问冲突
- 电影爱好者福利,一些电影网站汇总
- unity自己遇到的一些bug与解决方法的记录
- 【题解】Cutting Woods
- C#中的DoEvents()
- SitePoint Smackdown:Atom,括号,Light Table,Sublime Text