我正在使用 ansible 在我的 AWS 环境中部署 mattermost。我正在尝试设置安全的 https 连接,但进入日志时一直出现此错误:
{:"commands/server.go:112","msg":"listen tcp :443: bind: permission denied"}
{:"app/app.go:257","msg":"Stopping Server..."}
{:"app/web_hub.go:120","msg":"stopping websocket hub connections"}
{:"app/web_hub.go:125","msg":"We appear to have already sent the stop checking for deadlocks
我有点觉得这是某种权限错误,但我不知道该如何解决。有人能帮忙吗?
答案1
在 Linux 中,只有 root 可以绑定到 1024 以下的端口。典型的 Ansible 用例不是以 root 身份运行。
看https://docs.ansible.com/ansible/2.4/become.html关于 Ansible 中的权限提升。
看https://superuser.com/a/892391/155147寻找允许特权端口绑定的可能解决方案。
答案2
将 Grafana 升级到新版本后,我也遇到了类似的问题。
sudo service grafana-server status
正在打印:
grafana-vm systemd[1]: grafana-server.service: Main process exited, code=exited, status=1/FAILURE
grafana-vm systemd[1]: grafana-server.service: Unit entered failed state.
grafana-vm systemd[1]: grafana-server.service: Failed with result 'exit-code'.
grafana-vm systemd[1]: grafana-server.service: Service hold-off time over, scheduling restart.
grafana-vm systemd[1]: Stopped Grafana instance.
grafana-vm systemd[1]: grafana-server.service: Start request repeated too quickly.
grafana-vm systemd[1]: Failed to start Grafana instance.
grafana-vm systemd[1]: grafana-server.service: Unit entered failed state.
grafana-vm systemd[1]: grafana-server.service: Failed with result 'start-limit-hit'.
日志摘录:
lvl=eror msg="Stopped HTTPServer" logger=server reason="failed to open listener on address 0.0.0.0:80: listen tcp 0.0.0.0:80: bind: permission denied"
lvl=eror msg="A service failed" logger=server err="failed to open listener on address 0.0.0.0:80: listen tcp 0.0.0.0:80: bind: permission denied"
lvl=eror msg="Server shutdown" logger=server reason="failed to open listener on address 0.0.0.0:80: listen tcp 0.0.0.0:80: bind: permission denied"
事实证明这是一个解决办法:
sudo setcap 'cap_net_bind_service=+ep' /usr/sbin/grafana-server
更多的:https://grafana.com/docs/grafana/latest/administration/configuration/#http_port
答案3
可能回复太晚了,但这可以帮助某些人。我完全同意@Danko 的回答,但我找到了一种更好的方法。
如果您有该服务的 systemd 文件,那么您可以将以下内容放入您的 grafana.service 文件中。
[Service]
…
…
AmbientCapabilities = CAP_NET_BIND_SERVICE
CapabilityBoundingSet = CAP_NET_BIND_SERVICE
如果您想知道使用它的原因,可以阅读这个答案。 https://unix.stackexchange.com/a/581337/258106