@mr_mescaline

Баш скрипт гляньте плиз?

нужно на кроне обновлять(добавлять), ip прокси серверов cloudflare для nginx(set_real_ip_from).
хоть и не часто они обновляются, но все равно не хотелось бы лишний раз заходить на сервер.

на просторах нашел такой скрипт (по словам автора полностью рабочий)

#!/bin/bash

# Location of the nginx config file that contains the CloudFlare IP addresses.
CF_NGINX_CONFIG="/etc/nginx/cloudflare"

# The URLs with the actual IP addresses used by CloudFlare.
CF_URL_IP4="https://www.cloudflare.com/ips-v4"
CF_URL_IP6="https://www.cloudflare.com/ips-v6"

# Temporary files.
CF_TEMP_IP4="/tmp/cloudflare-ips-v4.txt"
CF_TEMP_IP6="/tmp/cloudflare-ips-v6.txt"

# Download the files.
if [ -f /usr/bin/curl ];
then
    curl --silent --output $CF_TEMP_IP4 $CF_URL_IP4
    curl --silent --output $CF_TEMP_IP6 $CF_URL_IP6
elif [ -f /usr/bin/wget ];
then
    wget --quiet --output-document=$CF_TEMP_IP4 --no-check-certificate $CF_URL_IP4
    wget --quiet --output-document=$CF_TEMP_IP6 --no-check-certificate $CF_URL_IP6
else
    echo "Unable to download CloudFlare files."
    exit 1
fi

# Generate the new config file.
echo "# CloudFlare IP Ranges" > $CF_NGINX_CONFIG
echo "# Generated at $(date) by $0" >> $CF_NGINX_CONFIG
echo "" >> $CF_NGINX_CONFIG

echo "# - IPv4 ($CF_URL_IP4)" >> $CF_NGINX_CONFIG
awk '{ print "set_real_ip_from " $0 ";" }' $CF_TEMP_IP4 >> $CF_NGINX_CONFIG
echo "" >> $CF_NGINX_CONFIG

echo "# - IPv6 ($CF_URL_IP6)" >> $CF_NGINX_CONFIG
awk '{ print "set_real_ip_from " $0 ";" }' $CF_TEMP_IP6 >> $CF_NGINX_CONFIG
echo "" >> $CF_NGINX_CONFIG

echo "real_ip_header CF-Connecting-IP;" >> $CF_NGINX_CONFIG
echo "" >> $CF_NGINX_CONFIG

# Remove the temporary files.
rm $CF_TEMP_IP4 $CF_TEMP_IP6

# Reload the nginx config.
service nginx reload


-------------------
не создается конфиг, нет его и во временных файлах. сами файлы со списками ip доступны (https://www.cloudflare.com/ips-v4 и https://www.cloudflare.com/ips-v6)

если в терминале вбить /home/scripts/cloudflare-update-ip-ranges.sh > /dev/null 2>&1

выводит такое:

/home/scripts/cloudflare-update-ip-ranges.sh
/home/scripts/cloudflare-update-ip-ranges.sh: line 29: /etc/nginx/cloudflare: Is
a directory
/home/scripts/cloudflare-update-ip-ranges.sh: line 30: /etc/nginx/cloudflare: Is
a directory
/home/scripts/cloudflare-update-ip-ranges.sh: line 31: /etc/nginx/cloudflare: Is
a directory
/home/scripts/cloudflare-update-ip-ranges.sh: line 33: /etc/nginx/cloudflare: Is
a directory
/home/scripts/cloudflare-update-ip-ranges.sh: line 34: /etc/nginx/cloudflare: Is
a directory
/home/scripts/cloudflare-update-ip-ranges.sh: line 35: /etc/nginx/cloudflare: Is
a directory
/home/scripts/cloudflare-update-ip-ranges.sh: line 37: /etc/nginx/cloudflare: Is
a directory
/home/scripts/cloudflare-update-ip-ranges.sh: line 38: /etc/nginx/cloudflare: Is
a directory
/home/scripts/cloudflare-update-ip-ranges.sh: line 39: /etc/nginx/cloudflare: Is
a directory
/home/scripts/cloudflare-update-ip-ranges.sh: line 41: /etc/nginx/cloudflare: Is
a directory
/home/scripts/cloudflare-update-ip-ranges.sh: line 42: /etc/nginx/cloudflare: Is
a directory
Reloading nginx: [ OK ]
  • Вопрос задан
  • 149 просмотров
Пригласить эксперта
Ответы на вопрос 1
nightvich
@nightvich
ITman
# Location of the nginx config file that contains the CloudFlare IP addresses.
CF_NGINX_CONFIG="/etc/nginx/cloudflare"
/home/scripts/cloudflare-update-ip-ranges.sh: line 29: /etc/nginx/cloudflare: Is
a directory


Путь правильный попробуйте написать.
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы