تثبيت Squid Proxy على خادم Linux

إذا كنت تريد إنشاء خادم بروكسي خاص بك بدلاً من استئجار خدمة، فإن Squid هو الملك المتوج في هذا المجال. Squid هو خادم تخزين مؤقت (Caching Proxy) قوي جداً، يستخدمه مزودو الإنترنت والشركات الكبرى لتسريع الويب وتوفير الباندويث. في هذا الدليل، سنقوم بتثبيته على خادم Ubuntu.

الخطوة 1: التثبيت

افتح التيرمينال واتصل بخادمك، ثم نفذ الأوامر التالية:

sudo apt update
sudo apt install squid -y

بعد التثبيت، سيعمل Squid تلقائياً. يمكنك التأكد من حالته بالأمر:

sudo systemctl status squid

الخطوة 2: ضبط الإعدادات الأساسية

ملف الإعدادات الرئيسي يقع في /etc/squid/squid.conf. قبل التعديل، لنأخذ نسخة احتياطية:

sudo cp /etc/squid/squid.conf /etc/squid/squid.conf.original
sudo nano /etc/squid/squid.conf

السماح بالاتصال (ACL)

بشكل افتراضي، يرفض Squid الاتصالات الخارجية. ابحث عن السطر http_access deny all وقم بتغييره للسماح لعنوان IP الخاص بك فقط (للأمان):

acl my_ip src 192.168.1.50  # ضع عنوان IP جهازك هنا
http_access allow my_ip

أو يمكنك السماح للجميع (خطر أمني!) بتغييرها إلى http_access allow all.

تغيير المنفذ

المنفذ الافتراضي هو 3128. يمكنك تغييره بالبحث عن:

http_port 3128

الخطوة 3: حماية البروكسي بكلمة مرور

لمنع الغرباء من استخدام خادمك، يجب إعداد مصادقة. سنحتاج لأداة apache2-utils:

sudo apt install apache2-utils -y
sudo htpasswd -c /etc/squid/passwd myusername

ثم أضف هذه السطور في ملف الإعدادات squid.conf:

auth_param basic program /usr/lib/squid/basic_ncsa_auth /etc/squid/passwd
auth_param basic realm My Private Proxy
acl authenticated proxy_auth REQUIRED
http_access allow authenticated

الخطوة 4: إعادة التشغيل

احفظ الملف واخرج، ثم أعد تشغيل الخدمة:

sudo systemctl restart squid

مبروك! لديك الآن خادم بروكسي خاص بك جاهز للاستخدام.

Disclosure: we may earn a commission if you purchase through some links.

Services Related To This Article

These offers are related to privacy, password security, and development workflows. Replace the current links with your real affiliate links through environment variables.

Default Links Need Replacement

Proton

Privacy, mail, and VPN

A strong fit for privacy-focused visitors who want VPN and secure email under one brand.

Explore Proton

Surfshark

Consumer VPN

Best on pages about geo-blocking, privacy, and public Wi-Fi protection.

Try Surfshark

NordVPN

High-converting VPN

A clear offer for users who need a paid, more durable alternative to a free proxy.

View NordVPN

1Password

Password management

The best match for password, secrets, team access, and personal security pages.

Discover 1Password

DigitalOcean

Developer cloud hosting

A strong fit for proxy setup, server, and infrastructure content aimed at developers and small teams.

Start with DigitalOcean