這裡介紹如何在 CentOS Linux 中安裝 Tor 與 Privoxy,自己架設匿名網頁代理伺服器。

先前我們介紹過在 Ubuntu Linux 中安裝 Tor 與 Privoxy 架設匿名網頁代理伺服器的方法,而這裡是改用 CentOS Linux 來架設的步驟,方法大同小異。

啟用 EPEL

在 CentOS Linux 中若要安裝 Tor 與 Privoxy 套件,必須先啟用 EPEL(若先前已經啟用,就可以跳過):

# 啟用 EPEL
sudo yum install epel-release

安裝 Tor

使用 yum 安裝 Tor:

# 安裝 Tor
sudo yum install tor

安裝好之後,啟動 Tor 服務:

# 啟動 Tor 服務
sudo systemctl start tor

查看服務是否正常啟動:

# 查看 Tor 服務狀態
systemctl status tor
● tor.service - Anonymizing overlay network for TCP
   Loaded: loaded (/usr/lib/systemd/system/tor.service; disabled; vendor preset: disabled)
   Active: active (running) since 一 2018-04-09 07:23:27 CST; 3min 14s ago
  Process: 10701 ExecStartPre=/usr/bin/tor --runasdaemon 0 --defaults-torrc /usr/share/tor/defaults-torrc -f /etc/tor/torrc --verify-config (code=exited, status=0/SUCCESS)
 Main PID: 10702 (tor)
   CGroup: /system.slice/tor.service
           └─10702 /usr/bin/tor --runasdaemon 0 --defaults-torrc /usr/share/t...
[略]

若 Active 欄位顯示為 active (running) 就表示 Tor 服務已經正常啟動了。

確認沒問題之後,設定開機自動啟動 Tor 服務:

# 設定開機自動啟動 Tor 服務
sudo systemctl enable tor

安裝 Privoxy

使用 yum 安裝 Privoxy:

# 安裝 Privoxy
sudo yum install privoxy

修改 /etc/privoxy/config 這個 Privoxy 的設定檔,將整合 Tor 與 Privoxy 這一行設定的註解拿掉:

# To chain Privoxy and Tor, both running on the same system, you
# would use something like:
forward-socks5t   /               127.0.0.1:9050 .

整合 Tor 與 Privoxy 之後,我們就可以透過 Privoxy 的 localhost:8118 導向至 Tor 網路中,以匿名的方式上網了。

修改好 Privoxy 的設定,就可以啟動 Privoxy 服務:

# 啟動 Privoxy 服務
sudo systemctl start privoxy

檢查 Privoxy 服務狀態:

# 查看 Privoxy 服務狀態
systemctl status privoxy
● privoxy.service - Privoxy Web Proxy With Advanced Filtering Capabilities
   Loaded: loaded (/usr/lib/systemd/system/privoxy.service; disabled; vendor preset: disabled)
   Active: active (running) since 一 2018-04-09 07:31:19 CST; 8min ago
  Process: 10758 ExecStart=/usr/sbin/privoxy --pidfile /run/privoxy.pid --user privoxy /etc/privoxy/config (code=exited, status=0/SUCCESS)
 Main PID: 10759 (privoxy)
   CGroup: /system.slice/privoxy.service
           └─10759 /usr/sbin/privoxy --pidfile /run/privoxy.pid --user privo...
[略]

最後設定開機自動啟動 Privoxy 服務:

# 設定開機自動啟動 Privoxy 服務
sudo systemctl enable privoxy

Privoxy 的設定方法在各種 Linux 發行版中都相同,請直接參考 Ubuntu Linux 安裝 Tor 與 Privoxy 的教學