nginx: add locations for netdata

This commit is contained in:
hayzam 2023-02-27 11:50:44 +05:30
parent 326d8e2b52
commit 60f65847e2

View file

@ -1,8 +1,8 @@
#!/bin/sh
if nginx -V 2>&1 | grep -q ubus; then
if [ -z "$(cat /etc/nginx/conf.d/luci.locations | grep ubus)" ]; then
cat <<EOT >> /etc/nginx/conf.d/luci.locations
if [ -z "$(cat /etc/nginx/conf.d/luci.locations | grep ubus)" ]; then
cat <<EOT >> /etc/nginx/conf.d/luci.locations
location /ubus {
ubus_interpreter;
@ -13,16 +13,23 @@ location /ubus {
location ~ ^/ttyd(.*)$ {
proxy_http_version 1.1;
proxy_set_header Upgrade \$http_upgrade;
proxy_read_timeout 300s;
proxy_connect_timeout 75s;
proxy_set_header Connection "upgrade";
proxy_pass http://\$server_addr:7681/\$1;
}
location ~ /netdata/(?<ndpath>.*) {
proxy_http_version 1.1;
proxy_pass http://$server_addr:19999/$ndpath$is_args$args;
}
EOT
fi
fi
fi
grep -q /var/run/ubus.sock /etc/nginx/conf.d/luci.locations &&
sed -i 's#/var/run/ubus.sock#/var/run/ubus/ubus.sock#' /etc/nginx/conf.d/luci.locations
sed -i 's#/var/run/ubus.sock#/var/run/ubus/ubus.sock#' /etc/nginx/conf.d/luci.locations
if [ -x /etc/init.d/uhttpd ]; then
/etc/init.d/uhttpd disable
@ -46,4 +53,4 @@ else
fi
exit 0
exit 0