LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 08-25-2011, 01:48 AM   #1
mathewparet
LQ Newbie
 
Registered: Aug 2011
Posts: 5

Rep: Reputation: Disabled
Question How to configure squid to route based on domain


I have a requirement which I couldnt figure out how to implement.

My server has only 1 IP

SQUID is listening to port 80

Apache is listening to port 8080

I want to configure squid such that:
1)Squid accepts all connections to port 80 (this is working find now)
2)If the request is for abc.com, it should route the page through apache - that is through 8080 (kind of a reverse proxy)
3)If the request is for ANY OTHER domain, squid should work as an open proxy server.

Thanks in advance.
 
Old 08-25-2011, 02:25 AM   #2
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
Hello and Welcome to LinuxQuestions,

If you have your firewall/router set up in a way that all webtraffic gets forwarded to the Squid server, then you can set up Squid as a reverse proxy to redirect traffic on domain name base. I've set it up with a lot of subdomains that way. Below is a part of my squid.conf for reference. Confidential information is 'changed'
Code:
cache_mgr root
#debug_options 61,3 ALL,9
# Basic parameters
visible_hostname www.domain.com
auth_param basic realm Domain Security Portal
error_directory  /usr/share/squid3/errors/English

# This line indicates the server we will be proxying for
#
http_port 192.168.253.20:80 defaultsite=www.domain.com vhost

https_port 192.168.253.20:443 accel cert=/etc/ssl/domain.crt key=/etc/ssl/domain.key defaultsite=www.domain.com vhost protocol=https
forwarded_for on

# And the IP Address for it - adjust the IP and port if necessary

cache_peer 172.X.X.X parent 443 0 no-query originserver ssl sslversion=3 sslflags=DONT_VERIFY_PEER front-end-https=on name=aut
acl site_aut dstdomain aut.domain.com
cache_peer_access aut allow site_aut
acl https proto https

cache_peer 172.X.X.X parent 443 0 no-query originserver ssl sslversion=3 sslflags=DONT_VERIFY_PEER front-end-https=on name=autlog
acl site_autlog dstdomain autlog.domain.com
cache_peer_access autlog allow site_autlog
acl https proto https

cache_peer 172.X.X.X parent 7002 0 no-query originserver ssl sslflags=DONT_VERIFY_PEER front-end-https=on name=auti2
acl site_auti2 dstdomain auti2.domain.com
cache_peer_access auti2 allow site_auti2
acl https proto https

cache_peer 172.X.X.X parent 443 0 no-query originserver ssl sslversion=3 sslflags=DONT_VERIFY_PEER front-end-https=on name=testfinance
acl site_testfinance dstdomain testfinance.domain.com
cache_peer_access testfinance allow site_testfinance
acl https proto https

cache_peer 172.X.X.X parent 443 0 no-query originserver ssl sslversion=3 sslflags=DONT_VERIFY_PEER front-end-https=on name=testmat
acl site_testmat dstdomain testmat.domain.com
cache_peer_access testmat allow site_testmat
acl https proto https

cache_peer 172.X.X.X parent 7002 0 no-query originserver ssl sslversion=3 sslflags=DONT_VERIFY_PEER front-end-https=on name=testmati2
acl site_testmati2 dstdomain testmati2.domain.com
cache_peer_access testmati2 allow site_testmati2
acl https proto https
This is only a part just to indicate how I configured the subdomains and the destination servers for them. It doesn't include any ACLs or access rules. All peers use https with a wildcard certificate.

Hope it helps. Looking forward to your participation in the forums. Have fun with Linux.

Kind regards,

Eric
 
Old 08-25-2011, 02:53 AM   #3
mathewparet
LQ Newbie
 
Registered: Aug 2011
Posts: 5

Original Poster
Rep: Reputation: Disabled
Thank you but this is not what I am looking for. Here it works only as a reverse proxy. Please read my question again.
 
Old 08-25-2011, 04:25 PM   #4
mathewparet
LQ Newbie
 
Registered: Aug 2011
Posts: 5

Original Poster
Rep: Reputation: Disabled
This is what I want. (Please read the original question first)


Someone types in: abc.com (then squid should route the request to apache running on port 81)

Someone types in yahoo.com (squid should proxy it as a normal web proxy)

Someone types in google.com (squid should proxy it as a normal web proxy)

In EricTRA's example he is using cache_peer for which we will have to hardcode the hostname or ip. However in my requirement it is not possible.

It should work like just any other squid installation (only thing is here it works on port 80) for all domains except abc.com (abc.com has to be redirected to apache with port 81*
 
Old 08-26-2011, 12:09 AM   #5
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
Hi,

Sorry for not understanding your original question the first time. I think you're looking for a redirector. Have a look at this site:
Squid Redirectors

Kind regards,

Eric
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Squid Redirect specific domain to an Secondary (External) Squid Proxy Zxarr Linux - Server 2 04-20-2010 12:50 PM
How to configure so I don't need to type domain name or FQDN for same domain hosts? lumix Linux - Newbie 1 05-22-2008 07:59 PM
route based on ports lhrt Linux - Networking 2 11-19-2006 11:06 PM
User based Authentication in Squid instead of Terminal based. TSK2000 Linux - Software 1 12-30-2005 02:22 AM
How to route my domain name to my server? benhalliday Linux - Software 9 08-17-2004 11:46 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 07:17 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration