LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 06-07-2004, 05:59 AM   #1
alaios
Senior Member
 
Registered: Jan 2003
Location: Aachen
Distribution: Opensuse 11.2 (nice and steady)
Posts: 2,203

Rep: Reputation: 45
squid and apache


Hi!
Do u know if is is possible to use a web server (apache) with a proxy server (squid) in the same machine?
I want to put the squid at the front lines ... The problem is that the http requests are made in the 80 port in which is used by the apache..
Thx
 
Old 06-07-2004, 09:13 AM   #2
doehn
LQ Newbie
 
Registered: Jun 2004
Location: Erlangen/Germany
Distribution: Debian 30r2
Posts: 11

Rep: Reputation: 0
Hi alaios

sure, that's possible. You only have to ensure, that the squid is listening on an other port e.g. 8080 (standard) and don't forget to configure your browser for don't using a Proxy for local connections.

have fun!

cu doehn
 
Old 06-07-2004, 09:18 AM   #3
alaios
Senior Member
 
Registered: Jan 2003
Location: Aachen
Distribution: Opensuse 11.2 (nice and steady)
Posts: 2,203

Original Poster
Rep: Reputation: 45
axa

But an http request is made on the 80 port.... How it can be processed firstly from squid and nor from the apache?
 
Old 06-07-2004, 09:50 AM   #4
doehn
LQ Newbie
 
Registered: Jun 2004
Location: Erlangen/Germany
Distribution: Debian 30r2
Posts: 11

Rep: Reputation: 0
Hi alaios,

if you use a proxy, you have to tell it to the browser. Then the request is done on port 8080. The browser tells the proxy on this port, that it want a web page and the proxy will get it for the browser. If you defined an address for not querying the proxy, the request is done directly from the browser.

If squid listens on port 80, it wouldn't understand the request, if it is a webserver request. It is a totally different protocol.

For a better understanding:

Request without proxy:
1. Request
Browser ------- :80-> Webserver
2. Answer
Browser <------------- Webserver



Request with proxy

1. Browser request
Browser ------- :8080-> Proxy
2. Proxy request
Proxy -------- :80-> Webserver
3. Answer to üroxy
Proxy <-------------- Webserver
4. Answer to browser
Browser <---------------- Proxy

The proxy is not acting like a webserver. This is done a little more tricky. But for understanding this, you first have to understand the basics of the http and tcp.

cu doehn
 
Old 06-07-2004, 09:52 AM   #5
alaios
Senior Member
 
Registered: Jan 2003
Location: Aachen
Distribution: Opensuse 11.2 (nice and steady)
Posts: 2,203

Original Poster
Rep: Reputation: 45
thx

I know these things...I want to talk about the tricky part
 
Old 06-07-2004, 10:03 AM   #6
doehn
LQ Newbie
 
Registered: Jun 2004
Location: Erlangen/Germany
Distribution: Debian 30r2
Posts: 11

Rep: Reputation: 0
Hi alaios,

well then...

the first tricky detail is, that the IP-Address is an internal IP. (I think, you know this, it's the same problem as nat)
the second is, that the browser has first to send it's requests to the proxy. The proxy won't reply if it is not his own IP or name.
This would be done, if you use net. So you have to send a request that is looking like this:
CONNECT http://www.xxx.yyy/zzz.html

Then the proxy GETs the page and sends it back to the browser.

This has to be done for every object you want to get over the HTTP protocol.

This also means that the proxy is able to cache the requests, nat isn't able, because it only knows the IP, not the full "path".

So, it is practice to not listen on port 80, because http and "proxy" is different.

The proxy will also get an address like this for you.

http://testserver.org:1234/

This is also http but it uses an other port.

Hope this is what you want to hear ;-)

cu doehn
 
Old 06-07-2004, 10:20 AM   #7
doehn
LQ Newbie
 
Registered: Jun 2004
Location: Erlangen/Germany
Distribution: Debian 30r2
Posts: 11

Rep: Reputation: 0
Hi alaios,

what you are thinking about is a transparent proxy.

This could be done with ipchains or iptables.

ipchains -A input -p tcp -s 192.168.100.0/24 -d 0/0 80 -j REDIRECT 8080

Then you are able to decide, if you want to redirect or not, but then apache has to listen on an other port.

You are able to do it like this:

ipchains -A input -p tcp -s <your_net> -d <your_server_ip> 80 -j REDIRECT 81
ipchains -A input -p tcp -s <your_net> -d 0/0 80 -j REDIRECT 8080

For this example, your proxy has to listen on 8080 and your apache on 81.
Don't forget to activate the kernel ip_forwarding feature:

echo 1 > /proc/sys/net/ipv4/ip_forward

cu doehn

Last edited by doehn; 06-07-2004 at 10:22 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
a little apache/squid-problem overlord73 Linux - Software 3 05-13-2005 01:09 AM
Problem with Squid + Apache Integration Charles Daniel Linux - Security 8 09-22-2004 05:49 AM
Using Squid and Apache in order to better serve pages xbaez Linux - Networking 2 04-07-2004 05:26 PM
Squid and Apache ???? vvandam Linux - Networking 9 07-18-2003 01:35 PM
Squid & Apache 80s Linux - Networking 2 01-10-2003 07:12 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 11:55 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