In the previous tutorial, we have seen the method of creating a gateway using iptables. This tutorial will focus on turning the gateway into a transparent proxy server. A proxy is called transparent when clients are not aware that their requests are processed through the proxy.

Добро всем времени суток,установил и настроил squid3, теперь возникла проблема безболезненного применения файла squid.conf, т.е. не перезагружая его! Нашел по статье http://www.k-max.name/linux/squid-proxy-v-linux/ следующее:
Программа squid3 с ключом -k и дополнительным параметром позволяет удобно управлять демоном, не прерывая пользователей. Примеры:
-k — послать команду работающему серверу: reconfigure — посылка сигнала HUP — перечитать и использовать файл конфигурации rotate — обрезать логи; сигнал USR1 shutdown — корректно остановить squid; сигнал TERM interrupt — убить squid; сигнал INT kill — жестко убить squid; сигнал KILL debug — начать/закончить полную трассировку; сигнал USR2 check — проверить корректность работы squid (без сообщений — работает корректно); сигнал ZERO parse — проверить синтаксис squid.conf
Собственно, изменив squid.conf, выполнив squid3 -k parse, можно убедиться в корректности внесенных изменений, далее выполнив squi3 -k reconfigure можно практически не обрывая пользователей применить изменения. Очистку кэша (пересоздание) можно выполнить командой squid3 -z.
Но не работает ни parse, ни reconfigure!! Может что то не так делаю! При вводе команды следующее:
После — пользователь, как ходил на запрещенный сайт, так и ходит! Только после перезагрузки сервера ему закрывается доступ!В чем причина не работы команд??
The best way to reconfigure a running Squid process is with the
squid -k reconfigure command:
% squid -k reconfigure
When you run this command, a HUP signal is sent to the running Squid
process. Squid then reads and parses the
squid.conf file. If the operation is successful,
you’ll see this in cache.log:
You need to be a little careful with the
reconfigure option because it’s
possible to make changes that cause a fatal error. For example, note
that Squid closes and reopens the incoming HTTP and ICP sockets. If
you change the to a port number that
Squid can’t open, it exits with a fatal error
message.
Certain options and directives can’t be changed
while Squid is running. This includes:
- Removal of cache directories (
directive).
- Changes to the directive.
- The directive
isn’t examined during the reconfigure procedure.
Thus, you can’t make Squid change its current
directory after it has started.


systemctl start squid, потом увидел что не стартует, начал разбираться и пришёл к тем данным которые в шапке
spellman
(31.03.22 10:33:34 MSK)
У комментатора не запускалось из-за наличия опции http_port 3128 intercept в конфиге. У тебя тоже есть эта строчка – может, оно.

Делай restart, чтобы systemd ошибку сбрасывал и запускал. А для перечитывания конфига есть reload.
Ну и смотри, что там в логах самого кальмара.
Radjah
(31.03.22 11:41:25 MSK)
Последнее исправление: Radjah 31.03.22 11:42:05 MSK
(всего
исправлений: 1)
В логах squid’а:
что это может значить?
spellman
(31.03.22 12:18:40 MSK)
Ему можно как-то помочь? Может в какой-нибудь каталог положить? Где их взять только)
spellman
(31.03.22 13:19:33 MSK)
После systemctl restart squid он запускается или сразу валится?
Попробуй запустить руками как-то так и посмотреть выхлоп:
Radjah
(31.03.22 14:25:14 MSK)
Выдало очень много строчек
и в конце
А как можно этоти порты сконфигурировать?
Полный вывод: https://controlc.com/8b8817bc
spellman
(31.03.22 14:53:12 MSK)
Заметил еще вот это:
Может там в файлах чего прописано лишнего?
Radjah
(31.03.22 16:01:02 MSK)
В каталоге /etc/squid/conf.d содержится файл debian.conf в котором следующие строки:
# Squid configuration settings for Debian
#
# Logs are managed by logrotate on Debian
logfile_rotate 0
# For extra security Debian packages only allow
# localhost to use the proxy on new installs
#
#http_access allow localnet
spellman
(01.04.22 16:18:29 MSK)
Просмотр полной версии : Перезапуск Squid с изменненой конфигурацией
Установлен squid (вер. 2.6) в связке с rejik. После того, как изменяю конфиг rejik, надо перезапустить squid. Так вот, если шлюз (FreeBSD 6.2) был недавно перегружен или squid после последней перезагрузки не передергивали, то он выдает на squid -k reconfigure такое:
squid: ERROR: Could not send signal 1 to process 14553: (3) No such process
Всё лечится убиением процесса squid через killall и последующим его ручным запуском. При следующей перегрузке шлюза всё по старому 🙁
Подскажите, в чем косяк может быть?
а у процесса сквида действительно такой ID, или это просто pid-файл по какой-то причине не обновляется?
еще глупый вариант:
sudo squid -k reconfigure
После этого без изменения конфига запустил команду:
# squid -k reconfigure
squid: ERROR: Could not send signal 1 to process 70994: (3) No such process
По моему мнению, действительно, вполне вероятно, что это старый pid.
Только у меня остался вопрос в плане любознательности — почему же так изначально получается, что первый раз squid запускается именно от имени рута, иначе мне не объяснить такие права у squid.pid ?
P.s. Система — FreeBSD 6.2, ставил всё из портов.
а как насчет /etc/rc.d/init.d/squid reload
Тогда получается, что после установки Squid надо прописать его в автозагрузку и перезапустить машину. Иначе при запуске вручную сразу после установки получим мою ситуацию.
Попробуйте заново поставит сквид там нечего сложного нету
Доброго времени суток. Поставил на CentOS 7 x64 squid. Ставил через yum. Если делаем
, то все работает отлично. А если сделать
, то после перезагрузки
и squid не работает. В файле конфигурации squid прописал
visible_hostname fw
pid_filename /run/squid.pid
результат тот же.
Попробовал
chown squid:squid /run/squid.pid
Не помогло, причем после перезагрузки хозяином снова становится root, а не squid. Порыл и выяснил, что squid.pid находится и в /run/ и в /var/run/ . Пробовал играть и с /run/squid.pid и с /var/run/squid.pid
Вот файл squid
В общем господа спецы хелп ми.
Combining Multiple ACLs
# vim /etc/squid/custom-denied-list-file
# vim /etc/squid/squid.conf
Preliminary
Before starting the configuration, we clarify a few points.
Squid Configuration Parsing
explicit allow
explicit deny
allow entire LAN
deny all
Squid restart vs. Squid reconfigure
This command will allow Squid to run with updated parameters without restarting itself.
Setting Maximum Download Size
Squid can be used to control the maximum downloadable file size. We want to restrict maximum download size to 50MB for hosts 10.10.10.200 and 10.10.10.201. We have already created the ACL custom-denied-list previously to isolate the traffic from these sources. Now we will use the same access list to restrict download size.
reply_body_max_size 50 MB custom-denied-list
Squid Installation
To set up a transparent proxy with Squid, we start by adding necessary iptables rules. These rules should help you get started, but please make sure that they do not conflict with any of the existing configuration.
# iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
# iptables -t nat -A PREROUTING -i eth0 -p tcp —dport 80 -j REDIRECT —to-port 3128
The first rule will cause all outbound packets from eth1 (WAN interface) to have the source IP address of eth1 (i.e., enable NAT). The second rule will redirect all incoming HTTP packets (destined to TCP 80) from eth0 (LAN interface) to Squid listening ort (TCP 3128), instead of forwarding it out to WAN interface right away.
We start Squid installation by using yum.
# yum install squid
Now we will modify Squid configuration to turn it into a transparent proxy. We define our LAN subnet (e.g., 10.10.10.0/24) as a valid client network. Any traffic not originating from the LAN subnet will be denied access.
visible_hostname proxy.example.tst
http_port 3128 transparent
## Define our network ##
acl our_network src 10.10.10.0/24
## make sure that our network is allowed ##
http_access allow our_network
## finally deny everything else ##
http_access deny all
Now we start Squid service and make sure it is added to startup.
# service squid start
# chkconfig squid on
# tailf /var/log/squid/access.log
1402987348.816 1048 10.10.10.10 TCP_MISS/302 752 GET http://www.google.com/ — DIRECT/173.194.39.178 text/html
1402987349.416 445 10.10.10.10 TCP_MISS/302 762 GET http://www.google.com.bd/? — DIRECT/173.194.78.94 text/html
According to the log file, the machine with IP 10.10.10.10 tried to access google.com and Squid processed the request.
The most basic form of Squid proxy server is now ready. In the rest of the tutorial, we will be tuning some parameters of Squid to control outbound traffic. Note that this is for demonstration only. Actual policies should be customized to meet your requirements.
Setting up Squid Caching Hierarchy
To enable caching, we modify the configuration file squid.conf.
cache_dir ufs /var/spool/squid 100 16 256
- 100MB storage is allocated for Squid cache. You may increase the allocated space if you want.
- 16 directories, each containing 256 subdirectories will be used to store cache files. This parameter should not be modified.
We can verify whether Squid cache is enabled from the log file /var/log/squid/access.log. For successful cache hits, we should see entries with TCP_HIT.
Hope this helps.
Filtering LAN Hosts by IP Address
In this demonstration, we want to set up Squid such that hosts with IP address 10.10.10.24 and 10.10.10.25 are prevented from accessing the Internet. We create a text file denied-ip-file containing the IP addresses of all denied hosts, and add that file in Squid configuration.
# vim /etc/squid/denied-ip-file
## first we create an ACL to isolate the denied IPs ##
acl denied-ip-list src «/etc/squid/denied-ip-file»
## then we apply the ACL ##
http_access deny denied-ip-list ## explicit deny ##
http_access allow our_network ## allow LAN ##
http_access deny all ## deny all ##
Now we need to restart Squid service. Squid will no longer honor requests from these IP addresses. If we check the squid log, we will find TCP_DENIED for requests originated from these hosts.
Filtering Websites in a Blacklist
# vim /etc/squid/badsite-file
## ACL definition ##
acl badsite-list url_regex «/etc/squid/badsite-file»
## ACL application ##
http_access deny badsite-list
http_access deny denied-ip-list ## previously set, no effect here ##
http_access allow our_network
http_access deny all

