I'm trying to run a squid server behind nginx. I configured nginx like this:
server {
listen 8080;
location / {
proxy_pass http://localhost:3128;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
Then I set my http network proxy to:
my-nginx-server-address:8080
So when I try to view the Google homepage, the nginx will get the request:
Get http://www.google.com/ HTTP/1.1
However when nginx pass the request to squid it will change the request_uri to
/
So squid won't work. Is there any way I can set the request_uri back to http://www.google.com then pass it to squid? Or any other ways I can run squid behind nginx?
Try proxy_set_header Request-URI $request_uri;
In reply to your comment, you may also prefer to add:
upstream _squid {
server localhost:3128;
}
server {
...
proxy_pass http://_squid/$host$uri;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With