Page 1 of 1

Why API is not working?

Posted: Sat Jul 25, 2020 7:19 pm
by dpeca
In myVesta, API is closed by default to all, because of better security.

You have to whitelist it for desired remote IP addresses.

How to whitelist remote IP for accessing /api/

In SSH console run:

Code: Select all

mkdir -p /usr/local/vesta/conf_web
pub_ip=$(curl -s
local_ip=$(ip addr|grep 'inet '|grep global|head -n1|awk '{print $2}'|cut -f1 -d/)
echo "$pub_ip" > /usr/local/vesta/conf_web/allow_ip_for_api.conf
if [ "$pub_ip" != "$local_ip" ]; then echo "$local_ip" >> /usr/local/vesta/conf_web/allow_ip_for_api.conf; fi
echo "" >> /usr/local/vesta/conf_web/allow_ip_for_api.conf
and add to /usr/local/vesta/conf_web/allow_ip_for_api.conf any other IP that should be able to access /api/ on that server.

You can add each IP per each line.