How do you setcap in Ubuntu 16.04.6 to allow Grafana to bind to port 80?

江枫思渺然 提交于 2020-06-01 05:08:18

问题


The Grafana config docs state that "To use port 80 you need to ... give the Grafana binary permission." When I run the instructed command

sudo setcap 'cap_net_bind_service=+ep' /usr/sbin/grafana-server

I get

Failed to set capabilities on file `/usr/sbin/grafana-server' (Invalid argument)
The value of the capability argument is not permitted for a file. Or the file is not a regular (non-symlink) file

When I run

sudo setcap ‘cap_net_bind_service=+ep’ /usr/sbin/grafana-server

I get

fatal error: Invalid argument
usage: setcap [-q] [-v] (-r|-|<caps>) <filename> [ ... (-r|-|<capsN>) <filenameN> ]

 Note <filename> must be a regular (non-symlink) file.

How do I allow Grafana to bind to port 80?


回答1:


I notice that /usr/sbin/ contains a file called grafana but not one named grafana-server. I changed the command to

sudo setcap cap_net_bind_service=+ep /usr/sbin/grafana

set port 80 in /etc/grafana/grafana.ini

# The HTTP port  to use
http_port = 80

then started the server again,

sudo systemctl start grafana-server

and it works fine. Perhaps this is a recent change that is awaiting an update in the Grafana docs.



来源:https://stackoverflow.com/questions/62088605/how-do-you-setcap-in-ubuntu-16-04-6-to-allow-grafana-to-bind-to-port-80

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!