mirror of
https://github.com/3proxy/3proxy.git
synced 2026-11-22 23:59:41 +08:00
Transparent moved to main code (TransparentPlugin removed), BSD pf support added
(cherry picked from commit 88b3225bdf)
This commit is contained in:
1 parent
69c6ddc8c4
commit
da66016c7f
19 files changed
+972
-191
No files matched your search
@@ -37,6 +37,7 @@
|
||||
<li><a href="#SSLPLUGIN">How to set up TLS/SSL (https proxy, mTLS)</a></li>
|
||||
<li><a href="#CERTIFICATES">How to create CA and certificates for SSL</a></li>
|
||||
<li><a href="#PCRE">How to use PCRE filtering (regular expressions)</a></li>
|
||||
<li><a href="#TRANSPARENT">How to proxy transparently</a></li>
|
||||
<li><A HREF="#AUTH">How to limit service access</a>
|
||||
<li><A HREF="#USERS">How to create a user list</a>
|
||||
<li><A HREF="#ACL">How to limit user access to resources</a>
|
||||
@@ -981,6 +982,189 @@ openssl pkcs12 -export -out client.p12 -passout pass: \
|
||||
openssl verify -x509_strict -CAfile ca.crt server.crt
|
||||
openssl verify -x509_strict -CAfile ca.crt client.crt
|
||||
</pre>
|
||||
|
||||
<li><a name="TRANSPARENT"><i>How to proxy transparently</i></a>
|
||||
<p>
|
||||
A transparent proxy serves clients that were never configured to use one. A
|
||||
packet filter redirects their connections to 3proxy, and the
|
||||
<b>transparent</b> command tells the service to take the destination from the
|
||||
filter instead of from the request. Every other feature applies as usual:
|
||||
access rules, parent proxies, limits and logging all see the real destination.
|
||||
It works on Linux and on the BSDs. Since 1.0.1 it is part of the binary; before
|
||||
that it was the separate TransparentPlugin, and the <b>plugin</b> line it
|
||||
needed is no longer required.
|
||||
</p>
|
||||
<p>
|
||||
The command supplies both the address and the port the client was trying to
|
||||
reach, so a service can serve whatever was redirected to it rather than one
|
||||
port with one target.
|
||||
</p>
|
||||
<p>
|
||||
Without it a service has to get a destination from somewhere else: an HTTP
|
||||
proxy falls back to the <b>Host</b> header, and a port mapper uses the address
|
||||
it was configured with. Taking the destination from the filter is what makes
|
||||
the other protocols work, and what makes the address authoritative rather than
|
||||
something the client claimed.
|
||||
</p>
|
||||
<p>
|
||||
<b>tlspr</b> is the clearest case. Nothing reaches it at all unless traffic is
|
||||
redirected to it, or the clients resolve the names to it through DNS. With a
|
||||
redirection it gets the address as well as the name from the handshake, and
|
||||
that is what lets access rules be written with host names: the name from the
|
||||
handshake is matched, and the connection still goes to the address the client
|
||||
was going to. Without the address it would have to resolve the name itself,
|
||||
which is a second lookup and a second answer.
|
||||
</p>
|
||||
<p>
|
||||
A configuration for web and TLS traffic:
|
||||
</p><pre>
|
||||
log /var/log/3proxy.log D
|
||||
auth iponly
|
||||
allow *
|
||||
|
||||
# the destination comes from the redirection for the services below
|
||||
transparent
|
||||
|
||||
# ordinary web traffic, redirected here from port 80
|
||||
proxy -p3129 -e192.0.2.10
|
||||
|
||||
# TLS, redirected here from port 443: tlspr would otherwise have only the
|
||||
# name in the handshake, and this gives it the address as well
|
||||
tlspr -p3143 -e192.0.2.10
|
||||
|
||||
notransparent
|
||||
</pre>
|
||||
<p>
|
||||
<b>-e</b> gives those services an address of their own to connect from. That
|
||||
address is what the redirection rules exclude, and excluding it is what stops
|
||||
the proxy's own connections from being redirected back into it. Without an
|
||||
exclusion the connection 3proxy makes to the origin matches the same rule,
|
||||
returns to 3proxy, and the traffic goes round until something gives out.
|
||||
Running 3proxy as its own account and excluding that account works too, and is
|
||||
the better choice when the machine has one address.
|
||||
</p>
|
||||
|
||||
<p><b>Linux, iptables</b>. For traffic the machine forwards for others:
|
||||
</p><pre>
|
||||
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-ports 3129
|
||||
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 443 -j REDIRECT --to-ports 3143
|
||||
</pre>
|
||||
<p>
|
||||
Traffic the machine generates itself passes through OUTPUT instead, where the
|
||||
proxy's own connections have to be excluded:
|
||||
</p><pre>
|
||||
# by the address the services connect from
|
||||
iptables -t nat -A OUTPUT -p tcp --dport 80 ! -s 192.0.2.10 -j REDIRECT --to-ports 3129
|
||||
|
||||
# or by the account 3proxy runs as
|
||||
iptables -t nat -A OUTPUT -p tcp --dport 80 -m owner ! --uid-owner proxy3 \
|
||||
-j REDIRECT --to-ports 3129
|
||||
</pre>
|
||||
|
||||
<p><b>Linux, nftables</b> (Debian 11+, Ubuntu 22.04+, RHEL 8+, Fedora, Arch,
|
||||
where nftables is what iptables is a front end for):
|
||||
</p><pre>
|
||||
table ip proxy3 {
|
||||
chain prerouting {
|
||||
type nat hook prerouting priority dstnat; policy accept;
|
||||
iif "eth0" tcp dport 80 redirect to :3129
|
||||
iif "eth0" tcp dport 443 redirect to :3143
|
||||
}
|
||||
|
||||
chain output {
|
||||
type nat hook output priority dstnat; policy accept;
|
||||
meta skuid != "proxy3" tcp dport 80 redirect to :3129
|
||||
meta skuid != "proxy3" tcp dport 443 redirect to :3143
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
<p>
|
||||
Load it with <b>nft -f</b>, and keep it across reboots in
|
||||
<b>/etc/nftables.conf</b> (Debian, Ubuntu) or
|
||||
<b>/etc/sysconfig/nftables.conf</b> (RHEL, Fedora). A table name cannot begin
|
||||
with a digit, which is why the table above is not called 3proxy.
|
||||
</p>
|
||||
|
||||
<p><b>Linux, firewalld</b> (RHEL, CentOS Stream, Fedora, openSUSE). Redirect an
|
||||
incoming port on a zone:
|
||||
</p><pre>
|
||||
firewall-cmd --permanent --zone=internal --add-forward-port=port=80:proto=tcp:toport=3129
|
||||
firewall-cmd --permanent --zone=internal --add-forward-port=port=443:proto=tcp:toport=3143
|
||||
firewall-cmd --reload
|
||||
</pre>
|
||||
<p>
|
||||
firewalld has no exclusion for the proxy's own traffic in that form, so put
|
||||
that part in a direct rule:
|
||||
</p><pre>
|
||||
firewall-cmd --permanent --direct --add-rule ipv4 nat OUTPUT 0 \
|
||||
-p tcp --dport 80 -m owner ! --uid-owner proxy3 -j REDIRECT --to-ports 3129
|
||||
firewall-cmd --reload
|
||||
</pre>
|
||||
|
||||
<p><b>Linux, ufw</b> (Ubuntu, Debian). ufw has no command for redirection;
|
||||
add the rules to <b>/etc/ufw/before.rules</b>, above the <b>*filter</b> block:
|
||||
</p><pre>
|
||||
*nat
|
||||
:PREROUTING ACCEPT [0:0]
|
||||
-A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-ports 3129
|
||||
-A PREROUTING -i eth0 -p tcp --dport 443 -j REDIRECT --to-ports 3143
|
||||
COMMIT
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
On Linux 3proxy asks the kernel where the connection was going. On the BSDs it
|
||||
asks pf, which keeps the original destination in its state table, through
|
||||
<b>/dev/pf</b> - so <b>rdr</b> rules work, and 3proxy has to be able to read
|
||||
that device. Where a redirection leaves the destination on the socket instead,
|
||||
that is used: OpenBSD <b>divert-to</b> and FreeBSD <b>ipfw fwd</b> both do.
|
||||
</p>
|
||||
<p>
|
||||
The mechanism is chosen automatically, and <b>transparent</b> takes an
|
||||
argument for the installations that need to pin it: <b>auto</b> (the default),
|
||||
<b>netfilter</b>, <b>pf</b>, or <b>socket</b> for reading it off the socket. A
|
||||
mode the build has no code for is refused, so a configuration written for
|
||||
another platform fails where it is wrong instead of quietly doing something
|
||||
else.
|
||||
</p>
|
||||
|
||||
<p><b>FreeBSD, NetBSD and OpenBSD, pf</b>. Redirect in <b>/etc/pf.conf</b>,
|
||||
excluding the address the proxy connects from:
|
||||
</p><pre>
|
||||
rdr pass on em0 inet proto tcp from ! 192.0.2.10 to any port 80 -> 127.0.0.1 port 3129
|
||||
rdr pass on em0 inet proto tcp from ! 192.0.2.10 to any port 443 -> 127.0.0.1 port 3143
|
||||
</pre>
|
||||
<p>
|
||||
Load with <b>pfctl -f /etc/pf.conf</b>. 3proxy looks the destination up in pf's
|
||||
state table, so it needs to read <b>/dev/pf</b>: either run it as root, or give
|
||||
its account access to that device.
|
||||
</p>
|
||||
|
||||
<p><b>OpenBSD, divert-to</b> is an alternative which leaves the destination on
|
||||
the socket, and needs no access to <b>/dev/pf</b>:
|
||||
</p><pre>
|
||||
pass in on em0 inet proto tcp to any port 80 divert-to 127.0.0.1 port 3129
|
||||
pass in on em0 inet proto tcp to any port 443 divert-to 127.0.0.1 port 3143
|
||||
</pre>
|
||||
|
||||
<p><b>FreeBSD, ipfw</b>. <b>fwd</b> delivers the connection locally without
|
||||
rewriting it, which also leaves the destination on the socket:
|
||||
</p><pre>
|
||||
ipfw add fwd 127.0.0.1,3129 tcp from any to any 80 in recv em0
|
||||
ipfw add fwd 127.0.0.1,3143 tcp from any to any 443 in recv em0
|
||||
</pre>
|
||||
|
||||
<p><b>macOS</b> has <b>/dev/pf</b> but ships no header for it, so a macOS build
|
||||
has no pf lookup, and macOS has neither <b>divert-to</b> nor ipfw to leave the
|
||||
address on the socket. Transparent proxying is not usable there, even though
|
||||
the commands exist in a macOS build.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Check the result by asking for a host through a redirected port and reading
|
||||
the log: the request should appear with the address the client asked for,
|
||||
which is what it would look like through a configured proxy.
|
||||
</p>
|
||||
|
||||
<li><a name="PCRE"><i>How to use PCRE filtering (regular expressions)</i></a>
|
||||
<p>
|
||||
Since version 0.9.7, PCRE (Perl Compatible Regular Expressions) filtering is built into
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
<li><a href="#SSLPLUGIN">Как настроить TLS/SSL (https прокси, mTLS)</a></li>
|
||||
<li><a href="#CERTIFICATES">Как создать CA и сертификаты для SSL</a></li>
|
||||
<li><a href="#PCRE">Как использовать PCRE-фильтрацию (регулярные выражения)</a></li>
|
||||
<li><a href="#TRANSPARENT">Как сделать транспарентный прокси</a></li>
|
||||
<li><a href="#AUTH">Как ограничить доступ к службе</a>
|
||||
<li><a href="#USERS">Как создать список пользователей</a>
|
||||
<li><a href="#ACL">Как ограничить доступ пользователей к ресурсам</a>
|
||||
@@ -992,6 +993,176 @@ openssl verify -x509_strict -CAfile ca.crt server.crt
|
||||
openssl verify -x509_strict -CAfile ca.crt client.crt
|
||||
</pre>
|
||||
|
||||
|
||||
<li><a name="TRANSPARENT"><i>Как сделать транспарентный прокси</i></a>
|
||||
<p>
|
||||
Транспарентный прокси обслуживает клиентов, которые не настроены на работу
|
||||
через прокси. Пакетный фильтр перенаправляет их соединения на 3proxy, а команда
|
||||
<b>transparent</b> указывает сервису брать адрес назначения у фильтра, а не из
|
||||
запроса. Всё остальное работает как обычно: правила доступа, родительские
|
||||
прокси, ограничения и логирование видят настоящий адрес назначения. Работает в
|
||||
Linux и BSD. С версии 1.0.1 встроено в бинарник, раньше это был отдельный
|
||||
TransparentPlugin, и строка <b>plugin</b> больше не нужна.
|
||||
</p>
|
||||
<p>
|
||||
Команда даёт и адрес, и порт назначения, поэтому сервис обслуживает всё, что
|
||||
на него перенаправлено, а не один порт с одним адресом назначения.
|
||||
</p>
|
||||
<p>
|
||||
Без неё сервис берёт адрес откуда-то ещё: HTTP-прокси - из заголовка
|
||||
<b>Host</b>, порт-маппер - из своей конфигурации. Именно получение адреса от
|
||||
фильтра позволяет работать с остальными протоколами и делает адрес
|
||||
достоверным, а не заявленным клиентом.
|
||||
</p>
|
||||
<p>
|
||||
Нагляднее всего это с <b>tlspr</b>. Без перенаправления трафика (или без
|
||||
резолва имён на него через DNS) на него вообще ничего не попадёт. С
|
||||
перенаправлением он получает и имя из TLS handshake, и адрес назначения -
|
||||
именно это позволяет писать правила доступа по именам хостов: имя из handshake
|
||||
проверяется в ACL, а соединение идёт на тот адрес, куда шёл клиент. Без адреса
|
||||
пришлось бы резолвить имя самостоятельно, то есть делать ещё один запрос и
|
||||
получать ещё один ответ.
|
||||
</p>
|
||||
<p>
|
||||
Конфигурация для веб- и TLS-трафика:
|
||||
</p><pre>
|
||||
log /var/log/3proxy.log D
|
||||
auth iponly
|
||||
allow *
|
||||
|
||||
# для сервисов ниже адрес назначения берётся из перенаправления
|
||||
transparent
|
||||
|
||||
# обычный веб-трафик, перенаправленный сюда с порта 80
|
||||
proxy -p3129 -e192.0.2.10
|
||||
|
||||
# TLS, перенаправленный сюда с порта 443: без этого у tlspr было бы только
|
||||
# имя из handshake, а так есть и адрес
|
||||
tlspr -p3143 -e192.0.2.10
|
||||
|
||||
notransparent
|
||||
</pre>
|
||||
<p>
|
||||
<b>-e</b> задаёт сервисам собственный адрес для исходящих соединений. Именно
|
||||
этот адрес исключается в правилах перенаправления, и это исключение не даёт
|
||||
соединениям самого прокси попасть обратно в него. Без исключения соединение,
|
||||
которое 3proxy устанавливает к серверу назначения, попадает под то же правило,
|
||||
возвращается в 3proxy, и трафик зацикливается. Можно вместо этого запускать
|
||||
3proxy под отдельной учётной записью и исключать её - так лучше, если у машины
|
||||
один адрес.
|
||||
</p>
|
||||
|
||||
<p><b>Linux, iptables</b>. Для транзитного трафика:
|
||||
</p><pre>
|
||||
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-ports 3129
|
||||
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 443 -j REDIRECT --to-ports 3143
|
||||
</pre>
|
||||
<p>
|
||||
Трафик самой машины проходит через цепочку OUTPUT, где соединения прокси нужно
|
||||
исключить:
|
||||
</p><pre>
|
||||
# по адресу, с которого сервисы устанавливают соединения
|
||||
iptables -t nat -A OUTPUT -p tcp --dport 80 ! -s 192.0.2.10 -j REDIRECT --to-ports 3129
|
||||
|
||||
# либо по учётной записи, под которой работает 3proxy
|
||||
iptables -t nat -A OUTPUT -p tcp --dport 80 -m owner ! --uid-owner proxy3 \
|
||||
-j REDIRECT --to-ports 3129
|
||||
</pre>
|
||||
|
||||
<p><b>Linux, nftables</b> (Debian 11+, Ubuntu 22.04+, RHEL 8+, Fedora, Arch):
|
||||
</p><pre>
|
||||
table ip proxy3 {
|
||||
chain prerouting {
|
||||
type nat hook prerouting priority dstnat; policy accept;
|
||||
iif "eth0" tcp dport 80 redirect to :3129
|
||||
iif "eth0" tcp dport 443 redirect to :3143
|
||||
}
|
||||
|
||||
chain output {
|
||||
type nat hook output priority dstnat; policy accept;
|
||||
meta skuid != "proxy3" tcp dport 80 redirect to :3129
|
||||
meta skuid != "proxy3" tcp dport 443 redirect to :3143
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
<p>
|
||||
Загружается через <b>nft -f</b>, сохраняется в <b>/etc/nftables.conf</b>
|
||||
(Debian, Ubuntu) или <b>/etc/sysconfig/nftables.conf</b> (RHEL, Fedora). Имя
|
||||
таблицы не может начинаться с цифры, поэтому таблица называется не 3proxy.
|
||||
</p>
|
||||
|
||||
<p><b>Linux, firewalld</b> (RHEL, CentOS Stream, Fedora, openSUSE):
|
||||
</p><pre>
|
||||
firewall-cmd --permanent --zone=internal --add-forward-port=port=80:proto=tcp:toport=3129
|
||||
firewall-cmd --permanent --zone=internal --add-forward-port=port=443:proto=tcp:toport=3143
|
||||
firewall-cmd --reload
|
||||
</pre>
|
||||
<p>
|
||||
Исключение для трафика самого прокси в таком виде не задаётся, для него нужно
|
||||
прямое правило:
|
||||
</p><pre>
|
||||
firewall-cmd --permanent --direct --add-rule ipv4 nat OUTPUT 0 \
|
||||
-p tcp --dport 80 -m owner ! --uid-owner proxy3 -j REDIRECT --to-ports 3129
|
||||
firewall-cmd --reload
|
||||
</pre>
|
||||
|
||||
<p><b>Linux, ufw</b> (Ubuntu, Debian). В ufw нет команды для перенаправления,
|
||||
правила добавляются в <b>/etc/ufw/before.rules</b> перед блоком <b>*filter</b>:
|
||||
</p><pre>
|
||||
*nat
|
||||
:PREROUTING ACCEPT [0:0]
|
||||
-A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-ports 3129
|
||||
-A PREROUTING -i eth0 -p tcp --dport 443 -j REDIRECT --to-ports 3143
|
||||
COMMIT
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
В Linux 3proxy спрашивает у ядра, куда шло соединение. В BSD он спрашивает у pf,
|
||||
который хранит исходный адрес назначения в таблице состояний, через
|
||||
<b>/dev/pf</b> - поэтому работают правила <b>rdr</b>, и 3proxy должен иметь
|
||||
доступ к этому устройству. Если перенаправление оставляет адрес на самом сокете,
|
||||
используется он: так делают OpenBSD <b>divert-to</b> и FreeBSD <b>ipfw fwd</b>.
|
||||
</p>
|
||||
<p>
|
||||
Механизм выбирается автоматически, а команда <b>transparent</b> принимает
|
||||
аргумент для случаев, когда его надо зафиксировать: <b>auto</b> (по умолчанию),
|
||||
<b>netfilter</b>, <b>pf</b> или <b>socket</b> для чтения адреса с сокета. Режим,
|
||||
которого нет в сборке, отвергается, поэтому конфигурация, написанная для другой
|
||||
платформы, не запустится вместо того, чтобы молча делать что-то другое.
|
||||
</p>
|
||||
|
||||
<p><b>FreeBSD, NetBSD, OpenBSD, pf</b>. Перенаправление в <b>/etc/pf.conf</b> с
|
||||
исключением адреса, с которого соединяется прокси:
|
||||
</p><pre>
|
||||
rdr pass on em0 inet proto tcp from ! 192.0.2.10 to any port 80 -> 127.0.0.1 port 3129
|
||||
rdr pass on em0 inet proto tcp from ! 192.0.2.10 to any port 443 -> 127.0.0.1 port 3143
|
||||
</pre>
|
||||
<p>
|
||||
Загружается через <b>pfctl -f /etc/pf.conf</b>. 3proxy ищет адрес назначения в
|
||||
таблице состояний pf, поэтому ему нужен доступ на чтение к <b>/dev/pf</b>: либо
|
||||
запуск от root, либо права на устройство для его учётной записи.
|
||||
</p>
|
||||
|
||||
<p><b>OpenBSD, divert-to</b> - альтернатива, оставляющая адрес на сокете, доступ
|
||||
к <b>/dev/pf</b> при этом не нужен:
|
||||
</p><pre>
|
||||
pass in on em0 inet proto tcp to any port 80 divert-to 127.0.0.1 port 3129
|
||||
pass in on em0 inet proto tcp to any port 443 divert-to 127.0.0.1 port 3143
|
||||
</pre>
|
||||
|
||||
<p><b>FreeBSD, ipfw</b>. <b>fwd</b> доставляет соединение локально, не переписывая
|
||||
его, и адрес тоже остаётся на сокете:
|
||||
</p><pre>
|
||||
ipfw add fwd 127.0.0.1,3129 tcp from any to any 80 in recv em0
|
||||
ipfw add fwd 127.0.0.1,3143 tcp from any to any 443 in recv em0
|
||||
</pre>
|
||||
|
||||
<p><b>macOS</b>: <b>/dev/pf</b> есть, но заголовочных файлов для него нет,
|
||||
поэтому в сборке под macOS нет обращения к pf, а ни <b>divert-to</b>, ни ipfw в
|
||||
macOS нет. Транспарентное проксирование там неприменимо, хотя команды в сборке
|
||||
присутствуют.
|
||||
</p>
|
||||
|
||||
<li><a name="PCRE"><i>Как использовать PCRE-фильтрацию (регулярные выражения)</i></a>
|
||||
<p>
|
||||
Начиная с версии 0.9.7 фильтрация PCRE встроена в 3proxy при компиляции с поддержкой
|
||||
|
||||
@@ -1,31 +1,56 @@
|
||||
<h3>3proxy TransparentPlugin (Linux/BSD only)</h3>
|
||||
<h3>3proxy transparent proxying (Linux/BSD only)</h3>
|
||||
|
||||
This plugin can turn 3proxy into a transparent proxy for virtually any TCP-based protocol
|
||||
and use all 3proxy features - redirections, parent proxies, ACLs, traffic limitations,
|
||||
etc. The TransparentPlugin takes the destination IP:port from Linux and uses this
|
||||
information as the target IP in the proxy. An example usage:
|
||||
Transparent proxying is part of 3proxy itself since 1.0.1. It was the separate
|
||||
TransparentPlugin before that, and the <b>plugin</b> line that used to load it
|
||||
is no longer needed: the <b>transparent</b> and <b>notransparent</b> commands
|
||||
are always available on the platforms that can redirect a connection.
|
||||
|
||||
<p>
|
||||
It turns 3proxy into a transparent proxy for virtually any TCP-based protocol,
|
||||
with the rest of 3proxy applying as usual - redirections, parent proxies, ACLs,
|
||||
traffic limitations and logging. The destination IP and port come from the
|
||||
packet filter that redirected the connection, and are used as the target of the
|
||||
proxied connection.
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
plugin /path/to/TransparentPlugin.ld.so transparent_plugin
|
||||
log /path/to/log
|
||||
auth iponly
|
||||
allow * * * 80
|
||||
parent 1000 http 0.0.0.0 0
|
||||
allow *
|
||||
parent 1000 socks5 SOCKS5_IP SOCKS5_PORT USER PASSWORD
|
||||
|
||||
transparent
|
||||
tcppm -iLOCAL_IP 12345 127.0.0.1 11111
|
||||
tcppm -eLOCAL_IP 12345 127.0.0.1 11111
|
||||
notransparent
|
||||
proxy
|
||||
</pre>
|
||||
Now, any TCP traffic transparently redirected to port 12345 will be routed via
|
||||
the parent SOCKSv5 proxy and logged; all URLs for web requests are visible in logs.
|
||||
The parameters '127.0.0.1 11111' in this case are not used and are overwritten by
|
||||
the destination IP:port for each transparent connection.
|
||||
|
||||
<h4>Download:</h4>
|
||||
<ul>
|
||||
<li>Plugin is included in 3proxy 0.8
|
||||
</li></ul>
|
||||
<p>
|
||||
Any TCP traffic redirected to port 12345 is routed through the parent SOCKSv5
|
||||
proxy and logged, with the URLs of web requests visible in the log. The
|
||||
'127.0.0.1 11111' arguments are not used in that case: they are replaced by the
|
||||
destination the client was trying to reach.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The destination is looked up in pf on the BSDs, through <b>/dev/pf</b>, and
|
||||
asked of the kernel on Linux; a redirection that leaves the address on the
|
||||
socket is used where there is one. <b>transparent</b> takes an optional
|
||||
<b>auto</b>, <b>netfilter</b>, <b>pf</b> or <b>socket</b> to pin that choice.
|
||||
</p>
|
||||
<p>
|
||||
The redirection rules must not match the connections 3proxy itself makes, or
|
||||
the traffic returns to the proxy and loops. Give the service an address to
|
||||
connect from with <b>-e</b> and exclude it in the rules, or run 3proxy as its
|
||||
own account and exclude that account.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Redirection rules for iptables, nftables, firewalld, ufw and pf are in
|
||||
<a href="../howtoe.html#TRANSPARENT">How to proxy transparently</a>, and the
|
||||
commands are described in 3proxy.cfg(5).
|
||||
</p>
|
||||
|
||||
© Vladimir Dubrovin, License: BSD style
|
||||
@@ -1,33 +1,56 @@
|
||||
<h3>Плагин TransparentPlugin 3proxy (только для Linux/BSD)</h3>
|
||||
<h3>Транспарентное проксирование 3proxy (только для Linux/BSD)</h3>
|
||||
|
||||
Плагин превращает 3proxy в транспарентный прокси для практически любых TCP-соединений
|
||||
и позволяет прозрачно для клиентов использовать весь фунционал прокси - редиректоры,
|
||||
родительские прокси, ACLи, ограничения трафика. TransparentPlugin получает IP:port
|
||||
назначения от Linux и использует эту информацию в качестве конечного адреса назначения.
|
||||
<br>
|
||||
Пример использования:
|
||||
Начиная с 1.0.1 транспарентное проксирование встроено в 3proxy. Раньше это был
|
||||
отдельный TransparentPlugin, и строка <b>plugin</b>, которой он загружался,
|
||||
больше не нужна: команды <b>transparent</b> и <b>notransparent</b> доступны
|
||||
всегда на тех платформах, где соединение можно перенаправить.
|
||||
|
||||
<p>
|
||||
3proxy становится транспарентным прокси практически для любых TCP-соединений,
|
||||
причём весь остальной функционал работает как обычно - редиректоры,
|
||||
родительские прокси, ACLи, ограничения трафика и логирование. IP и порт
|
||||
назначения берутся у пакетного фильтра, перенаправившего соединение, и
|
||||
используются как адрес назначения проксируемого соединения.
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
plugin /path/to/TransparentPlugin.ld.so transparent_plugin
|
||||
log /path/to/log
|
||||
auth iponly
|
||||
allow * * * 80
|
||||
parent 1000 http 0.0.0.0 0
|
||||
allow *
|
||||
parent 1000 socks5 SOCKS5_IP SOCKS5_PORT USER PASSWORD
|
||||
|
||||
transparent
|
||||
tcppm -iLOCAL_IP 12345 127.0.0.1 11111
|
||||
tcppm -eLOCAL_IP 12345 127.0.0.1 11111
|
||||
notransparent
|
||||
proxy
|
||||
</pre>
|
||||
Теперь любые TCP-соединения транспарентно перенаправленные в локальный порт 12345
|
||||
будут прологгированы и перенаправлены в родительский SOCKSv5 proxy, при этом для
|
||||
HTTP-запросов по порту TCP/80 будут видны параметры HTTP-запроса.
|
||||
Параметры '127.0.0.1 11111' в данном случае не оказывают влияния, т.к.
|
||||
будут перезаписываться IP и портом назначения для каждого TCP-соединения соответственно.
|
||||
<h4>Загрузить:</h4>
|
||||
<ul>
|
||||
<li>Плагин включен в дистрибутив 3proxy 0.8
|
||||
</li></ul>
|
||||
|
||||
<p>
|
||||
Любой TCP-трафик, перенаправленный на порт 12345, пойдёт через родительский
|
||||
SOCKSv5 прокси и будет залогирован, URL веб-запросов видны в логе. Аргументы
|
||||
'127.0.0.1 11111' в этом случае не используются: они заменяются адресом, к
|
||||
которому обращался клиент.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
В BSD адрес назначения ищется в pf через <b>/dev/pf</b>, в Linux запрашивается у
|
||||
ядра; если перенаправление оставляет адрес на сокете, используется он. Команда
|
||||
<b>transparent</b> принимает необязательный аргумент <b>auto</b>,
|
||||
<b>netfilter</b>, <b>pf</b> или <b>socket</b>, чтобы зафиксировать выбор.
|
||||
</p>
|
||||
<p>
|
||||
Правила перенаправления не должны попадать на соединения, которые устанавливает
|
||||
сам 3proxy, иначе трафик возвращается в прокси и зацикливается. Задайте сервису
|
||||
адрес для исходящих соединений через <b>-e</b> и исключите его в правилах, либо
|
||||
запускайте 3proxy под отдельной учётной записью и исключайте её.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Правила перенаправления для iptables, nftables, firewalld, ufw и pf приведены в
|
||||
<a href="../howtor.html#TRANSPARENT">описании транспарентного проксирования</a>,
|
||||
команды описаны в 3proxy.cfg(5).
|
||||
</p>
|
||||
|
||||
© Vladimir Dubrovin, License: BSD style
|
||||
Reference in new issue
Block a user