Answer the question
In order to leave comments, you need to log in
Nginx routing for squid, how to configure?
Good day to all.
Task: set up an nginx front that, depending on server_name, redirects tcp packets to a specific squid docker container that relays traffic further.
Those. there are third-level
domains fr.example.com
gd.example.com
nl.example.com
In the browser proxy settings, one of the domains is specified and the traffic goes first to nginx, then nginx, depending on the third-level domain, redirects traffic to one of CERTAIN squid ports.
fr.example.com --> localhost:7000
gd.example.com --> localhost:7001
nl.example.com --> localhost:7002
...
if I write in /etc/nginx/nginx.conf
stream {
upstream fr {
server localhost:7000;
}
server {
listen 8081;
proxy_pass fr8081;
proxy_responses 1;
}
}
upstream fr {
server 127.0.0.1:3128;
}
server {
listen 8080;
server_name fr.example.com;
location / {
proxy_read_timeout 1800;
proxy_connect_timeout 1800;
proxy_send_timeout 1800;
send_timeout 1800;
proxy_set_header Accept-Encoding "";
proxy_set_header X-Forwarded-By $server_addr:$server_port;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://fr;
}
}
Answer the question
In order to leave comments, you need to log in
> In the browser in the proxy settings, one of the domains is indicated
It will not work. Nginx server_name looks at the http header, and in it you pass www.google.com.
Better use different ports.
8080
8081
8082
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question