Как настроить локальный прокси для перенаправления трафика на удаленные прокси?

Я только что написал и протестировал в MacOS High Sierra:

#!/bin/sh

for fl in *.xml
do
    filename=$(echo $fl | cut -f 1 -d '.' | sed 's/_DANY$//')

    sed -i.orig '1a\
    <media:content url="'$filename'.mpg" type="video/mpg" expression="full" /> \
    ' $fl
done

ls *.xml     search in current directory
-i.orig     backup of original files with suffix
'1a..'      insert into second line

BSD sedв MacOS имеют несколько отличий от GNU sed, поэтому следующее выражение нужно писать отдельными строками:

'1a \        # backslash and newline
 some text'  

Символ новой строки \nне распознается, поэтому следует писать:

'1a \
some text   # newline here
'

вместо:

'1a \
some text\n'

Использование:

yurijs-MacBook-Pro:sed yurij$ cat *.xml
<description>Entrepreneur James overcame unconscionable childhood abuse before the sins of his past came back to haunt him.</description>
<media:rating>TV-14</media:rating>
<description>Entrepreneur James overcame unconscionable childhood abuse before the sins of his past came back to haunt him.</description>
<media:rating>TV-14</media:rating>
yurijs-MacBook-Pro:sed yurij$./cli
yurijs-MacBook-Pro:sed yurij$ cat *.xml
<description>Entrepreneur James overcame unconscionable childhood abuse before the sins of his past came back to haunt him.</description>
<media:content url="24ToLife_AFamilyDivided_191045.mpg" type="video/mpg" expression="full" />
<media:rating>TV-14</media:rating>
<description>Entrepreneur James overcame unconscionable childhood abuse before the sins of his past came back to haunt him.</description>
<media:content url="tt.mpg" type="video/mpg" expression="full" />
<media:rating>TV-14</media:rating>
1
04.04.2020, 11:39
1 ответ

Вам потребуется установить и настроить прокси-сервер локально. Все, что вы решите установить, само по себе должно поддерживать настройку для использования прокси-сервера.

Я бы начал с tinyproxy(см. пакет Ubuntu tinyproxy).

Похоже, это поддерживает правила для установки некоторых доменов через «восходящий поток». См. документацию:

  • Upstream, No Upstream

    This option allows you to set up a set of rules for deciding whether an upstream proxy server is to be used, based on the host or domain of the site being accessed. The rules are stored in the order encountered in the configuration file and the LAST matching rule wins. There are three possible forms for specifying upstream rules:

    • upstream host:port turns proxy upstream support on generally.
    • upstream host:port "site_spec" turns on the upstream proxy for the sites matching site_spec.
    • no upstream "site_spec" turns off upstream support for sites matching site_spec.

Первый тип правила отправляет все через другой прокси.

1
28.04.2021, 23:18

Теги

Похожие вопросы