问题
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