오징어 프록시 서버 구성

오징어 프록시 서버 구성

내 원격 서버(ubuntu 12.04)에 squid3 서버를 설치했는데, 이를 프록시 서버로 사용하고 싶습니다. 인터넷에 연결된 모든 컴퓨터에서 사용하려면 어떤 구성을 해야 합니까?

답변1

기본값에서 변경해야 하는 설정은 단 하나뿐입니다. http_port 라인. 그 소리에서 당신은 내가 설정한 것을 하고 싶어합니다. 투명 프록시로 오징어를 통해 트래픽을 자동으로 전환합니다. 이를 위해 해당 행은 다음과 같아야 합니다.

http_port 3128 transparent

나는 또한 내 시스템에서 dansguardian을 사용하므로 내 iptables 규칙이 작동하지 않을 수도 있지만 오징어를 통해 네트워크 외부로 들어오는 트래픽을 인터넷으로 보내는 데 이를 사용해야 합니다. 이 같은:

#!/bin/sh
# squid server IP
SQUID_SERVER="10.0.0.1"
# Interface connected to Internet
INTERNET="bond0"
# Interface for 10.0.0.1
LAN_IN="bond1"
# Dansguardian port
DG_PORT="8080"
#DG_PORT="3128"

echo "Applying proxy rules for packets routing through $LAN_IN -> $SQUID_SERVER:$DG_PORT"

# DO NOT MODIFY BELOW
# Clean old firewall
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X

iptables -P INPUT DROP
iptables -P OUTPUT ACCEPT

# Unlimited access to loop back
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT

# Allow UDP, DNS and Passive FTP
iptables -A INPUT -i $INTERNET -m state --state ESTABLISHED,RELATED -j ACCEPT

# set this system as a router for Rest of LAN
iptables --table nat --append POSTROUTING --out-interface $INTERNET -j MASQUERADE
iptables --append FORWARD --in-interface $LAN_IN -j ACCEPT

# unlimited access to LAN
iptables -A INPUT -i $LAN_IN -j ACCEPT
iptables -A OUTPUT -o $LAN_IN -j ACCEPT

# port forwarding

# HTTP (example)
iptables -t nat -A PREROUTING -i $INTERNET -p tcp --dport 80 -j DNAT --to 10.0.0.1:80
iptables -A INPUT -p tcp -m state --state NEW --dport 80 -i $INTERNET -j ACCEPT

# Divert traffic for external web pages through squid (dansguardian)
iptables -t nat -A PREROUTING -i $LAN_IN -p tcp --dport 80 -j DNAT --to $SQUID_SERVER:$DG_PORT
iptables -A OUTPUT -p tcp -o $LAN_IN --dport 80 -j ACCEPT

내 /etc/network/if-up.d/proxyrules에 이 스크립트의 (보다 구체화된) 버전이 있습니다. 몇 가지만 조정하면 행복하게 작동할 수 있습니다.

조정해야 할 또 다른 Squid 설정은 ACL입니다. 사람들이 귀하의 프록시 서버에 액세스할 수 있도록 허용합니다. 내 것은 기본값으로 작동하지만 Squid "액세스 거부" 오류를 해결하려면 이 섹션을 수정해야 할 수도 있습니다.

관련 정보