Welcome! Log In Create A New Profile

Advanced

Configure nginx with squid!

Posted by mathewparet 
Configure nginx with squid!
May 06, 2012 07:58AM
I have a requirement to configure nginx with squid. I have a vps with squid running on port 8080 and nginx on port 80.

Nginx acts as a cahe for an internal server. However I need squid also to be accessible in the same port, which is technically impossible.

So this is what I tried to do:

1) Configured squid to run on 8080 (by the way squid is working properly)
2) Configure nginx to send traffic to squid if incoming domain name ends with .com

Problem: it doesn't work. It just show thee squid home page as if squid is directly called in browser.

My nginx configuration:

server {
listen 80;
server_name *.com;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_cache STATIC;
proxy_cache_valid 200 1d;
proxy_cache_use_stale error timeout invalid_header updating
http_500 http_502 http_503 http_504;

}
}
server {
listen 80;
server_name bvm.glibix.com;

location / {
proxy_pass http://exmaple.org/;
proxy_set_header Host example.org;
proxy_cache STATIC;
proxy_cache_valid 200 1d;
proxy_cache_use_stale error timeout invalid_header updating
http_500 http_502 http_503 http_504;
}
}

Anyone has any idea how to do this? My requirement is simple. I should be able to access squid or my website using the same ip and port. What is served should be based on the domain name used in the browser. If i try to go to bvm.glibix.com (in the browser) it should show http://example.org content (this is working), and if i enter any other .com, it should route those requests to squid (not working) so that both can be done on the same port.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 186
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready