Постинг
27.06.2018 18:57 -
linux mint proxy server
От доста време се опитвам да пусна squid сървър със ауторизация на потребителя. За някои които четат тази статия това може да им се стори много просто и лесно и да възкликнат "ама че тъпанар, това е толкова просто, как може да се е мъчил толкова време"
Ами драги критици ако никога не си го правил, не си го учил и се мъчиш да го направиш започвайки от нулата... ами не е просто.
И понеже по подразбиране съм си прост, та си записах, че да не забравям, дано не забравя къде съм си сложил записките ;-)
Та сега по темата:
Всичко естествено се прави като root.
sudo su
Преди да зпочнем аз използвам nano текстов редактор но някои може би предпочитат vi
apt-get install nano
Оригиналният конфигурационен файл е огромен, около 8000 реда. Ужас... четох четох и накрая се отказах. И... взех че го орязах. Оставих някакви си 90 реда с коментарийте само на това което се използва. Тогава успях да се оправя.
И така, инсталираме прокси сървъра:
apt install squid3 -y
service squid start
За да работи сървъра му трябва апаче сървър:
apt install apache2
service apache2 start
Създаваме потребител с парола:
htpasswd -c /etc/squid3/squid_passwd user1
touch /etc/squid3/squid_passwd user1
Редактираме конфигурационния файл и добавяме в секцията собсрвени правила правилата за ауторизация:
nano /etc/squid3/squid.conf
#
# INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
#
auth_param basic program /usr/lib/squid3/basic_ncsa_auth /etc/squid3/squid_passwd
acl ncsa proxy_auth REQUIRED
acl google_users proxy_auth user1
acl block dstdomain "/etc/squid3/block.txt"
http_access deny block google_users
http_access allow ncsa
Създаваме файла за блокирани сайтове. При мен е празен защото така или иначе не проработи но ауторизацията проработи което е по-важно за мене.
nano /etc/squid3/block.txt
Примерно съдържание на файла:
.facebook.com
Рестартираме сървърите:
service squid3 restart
service apache2 restart
И... РАБОТИ :-)
И накрая моят конфигурационен файл:
# WELCOME TO SQUID 3.3.8
# ----------------------------
#
# ACCESS CONTROLS
# -----------------------------------------------------------------------------
# TAG: acl
#
# Recommended minimum configuration:
#
# Example rule allowing access from your local networks.
# Adapt to list your (internal) IP networks from where browsing
# should be allowed
#acl localnet src 10.0.0.0/8 # RFC1918 possible internal network
#acl localnet src 172.16.0.0/12 # RFC1918 possible internal network
#acl localnet src 192.168.0.0/16 # RFC1918 possible internal network
#acl localnet src fc00::/7 # RFC 4193 local private network range
#acl localnet src fe80::/10 # RFC 4291 link-local (directly plugged) machines
acl SSL_ports port 443 # https
acl SSL_ports port 563 # snews
acl SSL_ports port 873 # rsync
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 # https
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 1025-65535 # unregistered ports
acl Safe_ports port 280 # http-mgmt
acl Safe_ports port 488 # gss-http
acl Safe_ports port 591 # filemaker
acl Safe_ports port 777 # multiling http
acl Safe_ports port 631 # cups
acl Safe_ports port 873 # rsync
acl Safe_ports port 901 # SWAT
acl purge method PURGE
acl CONNECT method CONNECT
# TAG: http_access
#
# Recommended minimum Access Permission configuration:
#
# Deny requests to certain unsafe ports
http_access deny !Safe_ports
# Deny CONNECT to other than secure SSL ports
http_access deny CONNECT !SSL_ports
# Only allow cachemgr access from localhost
http_access allow localhost manager
http_access deny manager
#
# INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
#
auth_param basic program /usr/lib/squid3/basic_ncsa_auth /etc/squid3/squid_passwd
acl ncsa proxy_auth REQUIRED
acl google_users proxy_auth user1
acl block dstdomain "/etc/squid3/block.txt"
http_access deny block google_users
http_access allow ncsa
# Example rule allowing access from your local networks.
# Adapt localnet in the ACL section to list your (internal) IP networks
# from where browsing should be allowed
#http_access allow localnet
http_access allow localhost
# And finally deny or allow all other access to this proxy
# default: deny
http_access deny all
# NETWORK OPTIONS
# -----------------------------------------------------------------------------
# Squid normally listens to port 3128
http_port 3128
# OPTIONS FOR TUNING THE CACHE
# -----------------------------------------------------------------------------
# TAG: refresh_pattern
#
# Add any of your own refresh_pattern entries above these.
#
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern -i (/cgi-bin/|?) 0 0% 0
refresh_pattern (Release|Packages(.gz)*)$ 0 20% 2880
# example lin deb packages
#refresh_pattern (.deb|.udeb)$ 129600 100% 129600
refresh_pattern . 0 20% 4320
Ами драги критици ако никога не си го правил, не си го учил и се мъчиш да го направиш започвайки от нулата... ами не е просто.
И понеже по подразбиране съм си прост, та си записах, че да не забравям, дано не забравя къде съм си сложил записките ;-)
Та сега по темата:
Всичко естествено се прави като root.
sudo su
Преди да зпочнем аз използвам nano текстов редактор но някои може би предпочитат vi
apt-get install nano
Оригиналният конфигурационен файл е огромен, около 8000 реда. Ужас... четох четох и накрая се отказах. И... взех че го орязах. Оставих някакви си 90 реда с коментарийте само на това което се използва. Тогава успях да се оправя.
И така, инсталираме прокси сървъра:
apt install squid3 -y
service squid start
За да работи сървъра му трябва апаче сървър:
apt install apache2
service apache2 start
Създаваме потребител с парола:
htpasswd -c /etc/squid3/squid_passwd user1
touch /etc/squid3/squid_passwd user1
Редактираме конфигурационния файл и добавяме в секцията собсрвени правила правилата за ауторизация:
nano /etc/squid3/squid.conf
#
# INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
#
auth_param basic program /usr/lib/squid3/basic_ncsa_auth /etc/squid3/squid_passwd
acl ncsa proxy_auth REQUIRED
acl google_users proxy_auth user1
acl block dstdomain "/etc/squid3/block.txt"
http_access deny block google_users
http_access allow ncsa
Създаваме файла за блокирани сайтове. При мен е празен защото така или иначе не проработи но ауторизацията проработи което е по-важно за мене.
nano /etc/squid3/block.txt
Примерно съдържание на файла:
.facebook.com
Рестартираме сървърите:
service squid3 restart
service apache2 restart
И... РАБОТИ :-)
И накрая моят конфигурационен файл:
# WELCOME TO SQUID 3.3.8
# ----------------------------
#
# ACCESS CONTROLS
# -----------------------------------------------------------------------------
# TAG: acl
#
# Recommended minimum configuration:
#
# Example rule allowing access from your local networks.
# Adapt to list your (internal) IP networks from where browsing
# should be allowed
#acl localnet src 10.0.0.0/8 # RFC1918 possible internal network
#acl localnet src 172.16.0.0/12 # RFC1918 possible internal network
#acl localnet src 192.168.0.0/16 # RFC1918 possible internal network
#acl localnet src fc00::/7 # RFC 4193 local private network range
#acl localnet src fe80::/10 # RFC 4291 link-local (directly plugged) machines
acl SSL_ports port 443 # https
acl SSL_ports port 563 # snews
acl SSL_ports port 873 # rsync
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 # https
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 1025-65535 # unregistered ports
acl Safe_ports port 280 # http-mgmt
acl Safe_ports port 488 # gss-http
acl Safe_ports port 591 # filemaker
acl Safe_ports port 777 # multiling http
acl Safe_ports port 631 # cups
acl Safe_ports port 873 # rsync
acl Safe_ports port 901 # SWAT
acl purge method PURGE
acl CONNECT method CONNECT
# TAG: http_access
#
# Recommended minimum Access Permission configuration:
#
# Deny requests to certain unsafe ports
http_access deny !Safe_ports
# Deny CONNECT to other than secure SSL ports
http_access deny CONNECT !SSL_ports
# Only allow cachemgr access from localhost
http_access allow localhost manager
http_access deny manager
#
# INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
#
auth_param basic program /usr/lib/squid3/basic_ncsa_auth /etc/squid3/squid_passwd
acl ncsa proxy_auth REQUIRED
acl google_users proxy_auth user1
acl block dstdomain "/etc/squid3/block.txt"
http_access deny block google_users
http_access allow ncsa
# Example rule allowing access from your local networks.
# Adapt localnet in the ACL section to list your (internal) IP networks
# from where browsing should be allowed
#http_access allow localnet
http_access allow localhost
# And finally deny or allow all other access to this proxy
# default: deny
http_access deny all
# NETWORK OPTIONS
# -----------------------------------------------------------------------------
# Squid normally listens to port 3128
http_port 3128
# OPTIONS FOR TUNING THE CACHE
# -----------------------------------------------------------------------------
# TAG: refresh_pattern
#
# Add any of your own refresh_pattern entries above these.
#
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern -i (/cgi-bin/|?) 0 0% 0
refresh_pattern (Release|Packages(.gz)*)$ 0 20% 2880
# example lin deb packages
#refresh_pattern (.deb|.udeb)$ 129600 100% 129600
refresh_pattern . 0 20% 4320
ПРЕЗИДЕНТСКИТЕ ИЗБОРИ В СЛОВАКИЯ
Голямата игра започна: Русия и Китай „пр...
ЗАЩО НИКОГА НЯМА ДА СИ КУПЯ НЕЩО НА ИЗПЛ...
Голямата игра започна: Русия и Китай „пр...
ЗАЩО НИКОГА НЯМА ДА СИ КУПЯ НЕЩО НА ИЗПЛ...
Няма коментари