安装并配置webvirtmgr+supervisor后,WEB页面无法访问

现象:配置webvirtmgr+supervisor安装配置完成后,页面无法访问:

img

查看supervisor日志,发现如下内容看上去有问题:
2023-08-14 15:19:21,069 CRIT Supervisor is running as root. Privileges were not dropped because no user is specified in the config file. If you intend to run as root, you can set user=root in the config file to avoid this message.
2023-08-14 15:19:21,069 INFO Included extra file "/etc/supervisord.d/webvirtmgr.ini" during parsing
2023-08-14 15:19:21,087 INFO RPC interface 'supervisor' initialized
2023-08-14 15:19:21,088 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2023-08-14 15:19:21,088 INFO daemonizing the supervisord process
2023-08-14 15:19:21,089 INFO supervisord started with pid 19302
2023-08-14 15:19:22,092 INFO spawned: 'webvirtmgr-console' with pid 19304
2023-08-14 15:19:22,094 INFO spawned: 'webvirtmgr' with pid 19305
2023-08-14 15:19:23,483 INFO success: webvirtmgr-console entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2023-08-14 15:19:23,484 INFO success: webvirtmgr entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)

但是我的配置文件webvirtmgr.ini属主是root,并且也配置了user=root的内容,如下所示:

[program:webvirtmgr]
command=/usr/bin/python /data/webvirtmgr/manage.py run_gunicorn -c /data/webvirtmgr/conf/gunicorn.conf.py
directory=/data/webvirtmgr
autostart=true
autorestart=true
logfile=/var/log/supervisor/webvirtmgr.log
log_stderr=true
user=root
#user=nginx
 
[program:webvirtmgr-console]
command=/usr/bin/python /data/webvirtmgr/console/webvirtmgr-console
directory=/data/webvirtmgr
autostart=true
autorestart=true
stdout_logfile=/var/log/supervisor/webvirtmgr-console.log
redirect_stderr=true
user=root
#user=nginx


所以没看出有什么问题,不知道WEB页面无法访问是何原因?请教

【以下回答由 GPT 生成】

根据提供的日志和配置信息,可以看出supervisor已经成功启动并且运行了webvirtmgr和webvirtmgr-console两个进程。而且配置中也指定了以root用户运行进程。

问题的可能原因和解决方案如下:

  1. 未配置防火墙规则:首先要确保服务器上的防火墙规则允许对webvirtmgr的访问。可以使用以下命令检查是否存在防火墙规则:
sudo iptables -L

如果存在防火墙规则,而且没有针对webvirtmgr的允许访问规则,则需要添加以下规则:

sudo iptables -A INPUT -p tcp --dport 8000 -j ACCEPT
  1. 监听IP地址和端口是否正确:确保webvirtmgr正在监听正确的IP地址和端口。可以使用以下命令检查webvirtmgr的监听状态:
sudo netstat -tuln | grep 8000

如果没有监听IP地址和端口,则可能需要修改webvirtmgr的配置文件,以确保监听正确的IP地址和端口。 3. 服务未启动或未正确启动:确保webvirtmgr服务已经启动,并且没有发生错误。可以使用以下命令检查服务状态:

sudo supervisorctl status

如果服务未启动或者启动失败,可以尝试重启服务:

sudo supervisorctl restart webvirtmgr
sudo supervisorctl restart webvirtmgr-console
  1. 日志文件没有写入权限:确认日志文件目录是否有足够的写入权限,以及日志文件是否已经创建。可以使用以下命令检查日志文件的权限和存在情况:
ls -l /var/log/supervisor/webvirtmgr.log
ls -l /var/log/supervisor/webvirtmgr-console.log

如果没有写入权限或者文件不存在,则需要修改文件权限或者手动创建日志文件:

sudo touch /var/log/supervisor/webvirtmgr.log
sudo touch /var/log/supervisor/webvirtmgr-console.log
sudo chown root:root /var/log/supervisor/webvirtmgr.log
sudo chown root:root /var/log/supervisor/webvirtmgr-console.log

如果以上步骤都没有解决问题,可能是其他原因导致无法通过WEB页面访问。这需要根据具体情况进一步排查和调试。


如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^

supervisor的配置文件里面的user配置了吗