GNU/Linux >> Belajar Linux >  >> Cent OS

Cara Setup server proxy squid di CentOS/RHEL 7

Squid adalah aplikasi web proxy dengan berbagai konfigurasi dan kegunaan. Squid memiliki sejumlah besar kontrol akses dan mendukung protokol yang berbeda, seperti HTTP, HTTPS, FTP, dan SSL. Dalam postingan ini, kita akan melihat cara menggunakan Squid sebagai proxy HTTP.

Penyiapan

Squid adalah perangkat lunak yang cukup tua, matang, dan umum digunakan. Biasanya dikirimkan sebagai paket default dengan berbagai distribusi Linux.

Setup untuk posting ini:

192.168.10.2 - is our proxy server.
192.168.10.3 - Will redirect/cache traffic via the proxy server.

Menginstal proxy squid

Instal paket yang diperlukan untuk proxy squid, aktifkan layanan squid untuk memulai secara otomatis saat boot.

# yum install squid
# systemctl enable squid
# systemctl start squid

Anda mungkin menerima kesalahan di bawah ini jika Anda tidak memiliki versi openssl terbaru

Job for squid.service failed because the control process exited with error code. See "systemctl status squid.service" and "journalctl -xe" for details.

Untuk memastikannya, perbarui versi openssl menggunakan perintah di bawah ini:

# yum update openssl

Sekarang kita dapat melanjutkan dan memulai layanan quid.

# systemctl start squid

Mengonfigurasi proxy squid

Proxy squid secara default mendengarkan pada port 3128. Anda dapat mengubah port ini karena ini mungkin merupakan tindakan pencegahan keamanan untuk beberapa perusahaan. Edit file konfigurasi squid /etc/squid/squid.conf ubah arahan http_port untuk port 3128 jika Anda ingin mengubah port ini. Saya akan menjaga port tetap sama karena ini adalah pengaturan pengujian.

# vim /etc/squid/squid.conf
# Squid normally listens to port 3128
http_port 3128

Mulai ulang layanan squid agar perubahan diterapkan.

# systemctl restart squid

Verifikasi apakah proses proxy squid dimulai.

# ps -ef | grep squid
root      5403     1  0 03:21 ?        00:00:00 /usr/sbin/squid -f /etc/squid/squid.conf
squid     5405  5403  0 03:21 ?        00:00:00 (squid-1) -f /etc/squid/squid.conf
squid     5406  5405  0 03:21 ?        00:00:00 (logfile-daemon) /var/log/squid/access.log
root      5448  5158  0 03:24 pts/0    00:00:00 grep --color=auto squid

Anda juga dapat memverifikasi apakah proxy squid mendengarkan pada port 3128.

# ss -nlp | grep squid | grep 3128
tcp    LISTEN     0      128      :::3128                 :::*                   users:(("squid",pid=5405,fd=11))

Kami juga perlu mengizinkan port 3128 di firewalld, jika diaktifkan. Atau Anda cukup menonaktifkan firewalld sepenuhnya.

# firewall-cmd --add-port=3128/tcp --permanent

Siapkan server klien untuk menggunakan squid

# export http_proxy=http://${PROXY_FQDN}:8080

Di server jauh, untuk memverifikasi bahwa Anda dapat terhubung ke proxy, Anda dapat menjalankan curl ke google.com

# curl -v  http://google.com | head -1
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0* About to connect() to google.com port 80 (#0)
*   Trying 2607:f8b0:4009:804::200e...
* Connected to google.com (2607:f8b0:4009:804::200e) port 80 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.29.0
> Host: google.com
> Accept: */*
>
< HTTP/1.1 301 Moved Permanently
< Location: http://www.google.com/
< Content-Type: text/html; charset=UTF-8
< Date: Wed, 05 Jun 2019 07:28:26 GMT
< Expires: Fri, 05 Jul 2019 07:28:26 GMT
< Cache-Control: public, max-age=2592000
< Server: gws
< Content-Length: 219
< X-XSS-Protection: 0
< X-Frame-Options: SAMEORIGIN
<
{ [data not shown]
100   219  100   219    0     0   3145      0 --:--:-- --:--:-- --:--:--  3173
* Connection #0 to host google.com left intact


Cent OS
  1. Cara mengatur server SFTP di CentOS

  2. Cara Memasang Wayang Di CentOS 8 / RHEL 8

  3. Siapkan Server SysLog di CentOS 6 / RHEL 6

  1. Cara Setup SysLog Server di CentOS 7 / RHEL 7

  2. Cara Setup Server NFS di CentOS 7 / RHEL 7

  3. Cara Setup Server VNC untuk Pengguna Baru di CentOS/RHEL 5

  1. Cara Instal Squid Proxy Server di CentOS 7

  2. Cara menginstal server vnc di RHEL 8 / CentOS 8

  3. Cara Mengatur Server SVN di CentOS, RHEL &Fedora