Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Apache: Users

2 httpds on 1 server

 

 

Apache users RSS feed   Index | Next | Previous | View Threaded


list at meinsenf

Dec 11, 2001, 2:36 AM

Post #1 of 10 (249 views)
Permalink
2 httpds on 1 server

hi,

for testing a scenario:
my webserver (a single machine) has ONE name ("webserver"), but TWO IPs (10.0.0.1/2 - the DNS returns them rotational).
(in the future I should have two or three machines ...)

is it possible to let one apache run on port 8080 and the second on port 8090.
when a request goes to "10.0.0.1" it goes to port 8080
when a request goes to "10.0.0.2" it goes to port 8090

is this possible???

thanks for any help!!!

michi


obo at bourse

Dec 11, 2001, 2:51 AM

Post #2 of 10 (243 views)
Permalink
Re: 2 httpds on 1 server [In reply to]

Michael Reutter wrote:
>
> hi,
>
> for testing a scenario:
> my webserver (a single machine) has ONE name ("webserver"), but TWO IPs (10.0.0.1/2 - the DNS returns them rotational).
> (in the future I should have two or three machines ...)
>
> is it possible to let one apache run on port 8080 and the second on port 8090.
> when a request goes to "10.0.0.1" it goes to port 8080
> when a request goes to "10.0.0.2" it goes to port 8090

Ummm... I think you're a bit mixed up about TCP/IP. Apache is passive,
it listens for requests on defined IP addresses and port pairs. You can
make apache listen to any address and port using the Listen directive:

Listen 10.0.0.1:8080
<VirtualHost 10.0.0.1:8080>
VH directives...

However, the default port for HTTP is port 80 so the browser (which is
active) will send its request to port 80 - unless you want to put
"http://webserver:8080/" in all links to your site.

Note that since you are using different IP addresses, you can use the
same port for both virtual hosts. Defining a different IP address AND
port number for different VHs is overkill.

If you want that:

10.0.0.1:80 -> 10.0.0.1:8080

then you need to do address translation *before* you hit apache. That
means a firewall.

Rgds,

Owen Boyle.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe [at] httpd
For additional commands, e-mail: users-help [at] httpd


list at meinsenf

Dec 11, 2001, 3:05 AM

Post #3 of 10 (247 views)
Permalink
Re : Re: 2 httpds on 1 server [In reply to]

hi Owen,

of course apache itself can't direct the request to a specific port - but using a firewall is a good idea!!!!

but what about virtual-hosts (so one httpd would be enough!!!):
in the normal way you have many webs on one host (many names - one IP).
all requests go to the same ip - but apache can distinguish between them, by looking at the "host"-header.

you mean it is possible to do it the other way??? (would be great)
but how can apache distinguish between the requests?
one request goes to "webserver" and IP 10.0.0.1 and the other one goes to "webserver" and IP 10.0.0.2 - IMO it would work, if the requests do not go to "webserver", but to the IP itself (using http://10.0.0.2 instead of http://webserver)

if I could do it with virtual hosts - it would be great!!!!

thanks
michael

>Michael Reutter wrote:
>>
>> hi,
>>
>> for testing a scenario:
>> my webserver (a single machine) has ONE name ("webserver"), but TWO IPs (10.0.0.1/2 - the DNS returns them rotational).
>> (in the future I should have two or three machines ...)
>>
>> is it possible to let one apache run on port 8080 and the second on port 8090.
>> when a request goes to "10.0.0.1" it goes to port 8080
>> when a request goes to "10.0.0.2" it goes to port 8090
>
>Ummm... I think you're a bit mixed up about TCP/IP. Apache is passive,
>it listens for requests on defined IP addresses and port pairs. You can
>make apache listen to any address and port using the Listen directive:
>
>Listen 10.0.0.1:8080
><VirtualHost 10.0.0.1:8080>
> VH directives...
>
>However, the default port for HTTP is port 80 so the browser (which is
>active) will send its request to port 80 - unless you want to put
>"http://webserver:8080/" in all links to your site.
>
>Note that since you are using different IP addresses, you can use the
>same port for both virtual hosts. Defining a different IP address AND
>port number for different VHs is overkill.
>
>If you want that:
>
>10.0.0.1:80 -> 10.0.0.1:8080
>
>then you need to do address translation *before* you hit apache. That
>means a firewall.
>
>Rgds,
>
>Owen Boyle.
>
>---------------------------------------------------------------------
>The official User-To-User support forum of the Apache HTTP Server Project.
>See <URL:http://httpd.apache.org/userslist.html> for more info.
>To unsubscribe, e-mail: users-unsubscribe [at] httpd
>For additional commands, e-mail: users-help [at] httpd
>
>


derek at rivertower

Dec 11, 2001, 3:43 AM

Post #4 of 10 (247 views)
Permalink
Re: 2 httpds on 1 server [In reply to]

It is no problem if you use mod_redirect and mod_proxy to proxy the
connections to either www server.

Why not simply run your httpd server on the two ips and forget about the two
strange ports (8080 and 8090) ? apache has no problem binding virtual hosts
with multiple ip addresses.

Or, finally, to do your port to ip proxying you could use a firewall with
port/ip redirection - I know that both Checkpoint FW1 and IPFW both do this
(I dont really know any other firewalls).

Good Luck,

Derek

On Tuesday 11 December 2001 09:36, you wrote:

> > hi,
>
> for testing a scenario:
> my webserver (a single machine) has ONE name ("webserver"), but TWO IPs
> (10.0.0.1/2 - the DNS returns them rotational). (in the future I should
> have two or three machines ...)
>
> is it possible to let one apache run on port 8080 and the second on port
> 8090. when a request goes to "10.0.0.1" it goes to port 8080
> when a request goes to "10.0.0.2" it goes to port 8090
>
> is this possible???
>
> thanks for any help!!!
>
> michi

----------------------------------------
Content-Type: text/plain; charset="us-ascii"; name="Attachment: 1"
Content-Transfer-Encoding: 7bit
Content-Description:
----------------------------------------

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe [at] httpd
For additional commands, e-mail: users-help [at] httpd


obo at bourse

Dec 11, 2001, 4:28 AM

Post #5 of 10 (247 views)
Permalink
Re: Re : Re: 2 httpds on 1 server [In reply to]

Michael Reutter wrote:
>
> hi Owen,
>
> of course apache itself can't direct the request to a specific port - but using a firewall is a good idea!!!!
>
> but what about virtual-hosts (so one httpd would be enough!!!):
> in the normal way you have many webs on one host (many names - one IP).
> all requests go to the same ip - but apache can distinguish between them, by looking at the "host"-header.
>
> you mean it is possible to do it the other way??? (would be great)
> but how can apache distinguish between the requests?
> one request goes to "webserver" and IP 10.0.0.1 and the other one goes to "webserver" and IP 10.0.0.2 - IMO it would work, if the requests do not go to "webserver", but to the IP itself (using http://10.0.0.2 instead of http://webserver)

I'm a bit baffled about what you are trying to achieve. Do you one
servername in DNS which resolves randomly to one of two IP addresses and
each IP address leads to a different site?

Rgds,

Owen Boyle.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe [at] httpd
For additional commands, e-mail: users-help [at] httpd


derek at rivertower

Dec 11, 2001, 4:47 AM

Post #6 of 10 (246 views)
Permalink
Re: Re : Re: 2 httpds on 1 server [In reply to]

On Tuesday 11 December 2001 10:05, you wrote:

> > hi Owen,
>
> of course apache itself can't direct the request to a specific port - but
> using a firewall is a good idea!!!!

Apache can either redirect or proxy to individual ports - proxying will do
this perfectly although sometimes you have to do a few funny things with the
hosts file to allow name based virtual hosting with redirecting to work
within the one box - but it works and it works well (except that log files
get a bit messed around).

A firewall will also do the job fine but, perhaps, its a bit of an overkill.

> but what about virtual-hosts (so one httpd would be enough!!!):
> in the normal way you have many webs on one host (many names - one IP).
> all requests go to the same ip - but apache can distinguish between them,
> by looking at the "host"-header.
> you mean it is possible to do it the other way??? (would be great)
> but how can apache distinguish between the requests?
Check out the apache faq or the httpd.conf.default - it goes through the
Listen and NameVirtualHost directives.

Derek

> one request goes to "webserver" and IP 10.0.0.1 and the other one goes to
> "webserver" and IP 10.0.0.2 - IMO it would work, if the requests do not go
> to "webserver", but to the IP itself (using http://10.0.0.2 instead of
> http://webserver)
> if I could do it with virtual hosts - it would be great!!!!
>
> thanks
> michael
>
>
> >Michael Reutter wrote:
> >
> >>
> >> hi,
> >>
> >> for testing a scenario:
> >> my webserver (a single machine) has ONE name ("webserver"), but TWO IPs
> >> (10.0.0.1/2 - the DNS returns them rotational). (in the future I should
> >> have two or three machines ...)
> >>
> >> is it possible to let one apache run on port 8080 and the second on port
> >> 8090. when a request goes to "10.0.0.1" it goes to port 8080
> >> when a request goes to "10.0.0.2" it goes to port 8090
> >
> >
> >Ummm... I think you're a bit mixed up about TCP/IP. Apache is passive,
> >it listens for requests on defined IP addresses and port pairs. You can
> >make apache listen to any address and port using the Listen directive:
> >
> >Listen 10.0.0.1:8080
> ><VirtualHost 10.0.0.1:8080>
> > VH directives...
> >
> >However, the default port for HTTP is port 80 so the browser (which is
> >active) will send its request to port 80 - unless you want to put
> >"http://webserver:8080/" in all links to your site.
> >
> >Note that since you are using different IP addresses, you can use the
> >same port for both virtual hosts. Defining a different IP address AND
> >port number for different VHs is overkill.
> >
> >If you want that:
> >
> >10.0.0.1:80 -> 10.0.0.1:8080
> >
> >then you need to do address translation *before* you hit apache. That
> >means a firewall.
> >
> >Rgds,
> >
> >Owen Boyle.
> >
> >---------------------------------------------------------------------
> >The official User-To-User support forum of the Apache HTTP Server
> > Project. See <URL:http://httpd.apache.org/userslist.html> for more info.
> >To unsubscribe, e-mail: users-unsubscribe [at] httpd
> >For additional commands, e-mail: users-help [at] httpd
> >

----------------------------------------
Content-Type: text/plain; charset="us-ascii"; name="Attachment: 1"
Content-Transfer-Encoding: 7bit
Content-Description:
----------------------------------------

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe [at] httpd
For additional commands, e-mail: users-help [at] httpd


list at meinsenf

Dec 11, 2001, 6:12 AM

Post #7 of 10 (248 views)
Permalink
Re : Re: Re : Re: 2 httpds on 1 server [In reply to]

>> you mean it is possible to do it the other way??? (would be great)
>> but how can apache distinguish between the requests?
>> one request goes to "webserver" and IP 10.0.0.1 and the other one goes to "webserver" and IP 10.0.0.2 - IMO it would work, if the requests do not go to "webserver", but to the IP itself (using http://10.0.0.2 instead of http://webserver)
>
>I'm a bit baffled about what you are trying to achieve. Do you one
>servername in DNS which resolves randomly to one of two IP addresses and
>each IP address leads to a different site?
>

correct - the name is resolved (not randomly, but in rotation) by the DNS - and the request goes to the specific IP (to different machines in the future - but I have to simulate it now with only ONE machine!!!)

michi


obo at bourse

Dec 11, 2001, 7:03 AM

Post #8 of 10 (245 views)
Permalink
Re: Re : Re: Re : Re: 2 httpds on 1 server [In reply to]

Michael Reutter wrote:
>
> >> you mean it is possible to do it the other way??? (would be great)
> >> but how can apache distinguish between the requests?
> >> one request goes to "webserver" and IP 10.0.0.1 and the other one goes to "webserver" and IP 10.0.0.2 - IMO it would work, if the requests do not go to "webserver", but to the IP itself (using http://10.0.0.2 instead of http://webserver)
>
> ... the name is resolved (not randomly, but in rotation) by the DNS - and the request goes to the specific IP (to different machines in the future - but I have to simulate it now with only ONE machine!!!)

Leaving aside the issue of why you want alternate visitors to your site
to get a different page... I would proceed as follows:

- If you have no problems with using port 80, stick to that port -
everyone else does :-) (The only reason you might NOT want to use port
80 is if you don't want to start apache as root - then you have to use a
high-numbered port > 1024. But this is only commonly done in an intranet
environment).

- simply attach your sites to the distinct IP addresses using IP-based
virtual hosts; Something like:

Listen 192.168.1.1:80
<VirtualHost 192.168.1.1:80>
DocumentRoot /path/to/site_1
ServerName webserver
... other directives
</VirtualHost>

Listen 192.168.1.2:80
<VirtualHost 192.168.1.2:80>
DocumentRoot /path/to/site_2
ServerName webserver
... other directives
</VirtualHost>

Since the ServerName directives are in distinct VH containers, they will
not collide. Both sites are now handled by the same instance of apache.

Congratulations, this is the weirdest set-up I've ever come across. When
you get it working, please post your URL so I can visit your
schizophrenic site ;->

Rgds,

Owen Boyle.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe [at] httpd
For additional commands, e-mail: users-help [at] httpd


list at meinsenf

Dec 11, 2001, 8:17 AM

Post #9 of 10 (252 views)
Permalink
Re: 2 httpds on 1 server [In reply to]

>Listen 192.168.1.1:80
><VirtualHost 192.168.1.1:80>
> DocumentRoot /path/to/site_1
> ServerName webserver
> ... other directives
></VirtualHost>
>
>Listen 192.168.1.2:80
><VirtualHost 192.168.1.2:80>
> DocumentRoot /path/to/site_2
> ServerName webserver
> ... other directives
></VirtualHost>

this is, how it works! (I wasn't aware of the "Listen n.n.n.n" command)
the Listen command does the thing I thought apache can't handle (so it can lookup the IP *AFTER* processing the request)

>Congratulations, this is the weirdest set-up I've ever come across. When
>you get it working, please post your URL so I can visit your
>schizophrenic site ;->

:-) but so I can set up as many machines as I like to handle a huge load of static pages in the future!
now I can simulate this with already setup DNS round-robin by using the above configuration!!!

... and to make the setup much more weird: behind the apaches there are MANY tomcat-servers generating the dynamic pages (getting the requests by apache's mod_rewrite)...
... and it works great!!!

thanks
michi


obo at bourse

Dec 11, 2001, 9:26 AM

Post #10 of 10 (251 views)
Permalink
Re: 2 httpds on 1 server [In reply to]

Michael Reutter wrote:
>
> this is, how it works! (I wasn't aware of the "Listen n.n.n.n" command)
> the Listen command does the thing I thought apache can't handle (so it can lookup the IP *AFTER* processing the request)

Glad you got it working... Just one point however, apache doesn't
"lookup the IP *AFTER* processing the request". What happens is that
when it is started, apache tries to bind to all the IP:port pairs
defined by Listen directives (among others). If successful, apache comes
up with a ear glued to each of these. This is before any requests have
arrived. It then connects each ear to a virtualhost so if it hears a
request on a particular IP:port, it knows immediately which VH to go to
to find the DocumentRoot.

You have to have your machine already configured at the network level to
respond to all the IP addresses that apache is going to listen to before
you start apache (In fact, trying to Listen to a port that is already in
use or unavailable is a "failed to start" offence).

Rgds,

Owen Boyle.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe [at] httpd
For additional commands, e-mail: users-help [at] httpd

Apache users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.