LinuxQuestions.org
Help answer threads with 0 replies.
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 11-11-2005, 08:39 PM   #1
hgb
Member
 
Registered: Jun 2004
Distribution: Mandrake 10, SUSE 10.x, DEbian
Posts: 125

Rep: Reputation: 15
Apache2 virtual host.


Hi there, Im having problems with this, perhaps I havent understood completely the concepts...

Supose I have 2 DNS on the web

some1.domain.net
some2.domain.net

domain.net is a dynamic DNS service.


I have them poiting to my public IP address at port 8080.


Now, this is what Im trying to do:

Code:
Listen 8080

User hgb
Group users

# DocumentRoot /apache_start/sites/ # is necesary have this here???, I guess NO.
Options None

NameVirtualHost *

<VirtualHost *>
ServerName		some1.domain.net
DocumentRoot    /apache_start/sites/some2
</VirtualHost>

<VirtualHost *>
ServerName		some2.domain.net
DocumentRoot		/apache_start/sites/some1
</VirtualHost>


# create a <VirtualHost _default_:*> server that has no pages to serve???.. like this???
<VirtualHost _default_:*>
</VirtualHost>



LoadModule mime_module /usr/lib/apache2-prefork/mod_mime.so
TypesConfig /etc/apache2/mime.types
DefaultType text/plain
That is how Im doing now.

When I use the script that I put the code here somewhere that default the port to 8080 for test my site.... http://obp.host.sk/getpage.php?host=some2.domain.net and http://obp.host.sk/getpage.php?host=some1.domain.net I get the ansewr from both sites.. but

I get the same file for the two diferent request!!!!!, and is the index @ /apache_start/sites/some2 the first document root specificated inside a <VirtualHost> block, if I uncomment the documentroot outside the virtual host blocks, is the same result.





The thing is: how I will do the virtual host that will open the respective index.html for each path /apache_start/sites/some2 and /apache_start/sites/some1????
 
Old 11-12-2005, 12:06 AM   #2
Markild
LQ Newbie
 
Registered: Dec 2002
Distribution: Ubuntu
Posts: 16

Rep: Reputation: 0
If I remember correctly. The first vhost you define becomes the default by default.
Try to make that one empty. What concerns the both hosts returning the same site i don't know.

Just to eliminate things, try to have *:8080 instead of *
 
Old 11-12-2005, 12:21 AM   #3
hgb
Member
 
Registered: Jun 2004
Distribution: Mandrake 10, SUSE 10.x, DEbian
Posts: 125

Original Poster
Rep: Reputation: 15
Somebody sguest that I add to each virtual host

for server some1.site.com
Quote:
ServerAlias some1.*
And the other one similar.

I add the server Alias and I do
Quote:
#/usr/sbin/apache2ctl -f /apache_start/httpd.conf -k restart
#/usr/sbin/apache2ctl -S
VirtualHost configuration:
Syntax OK

I also found this (spanish) http://www.osmosislatina.com/apache/vhosting.htm

But reading that, I add this

Code:
LoadModule proxy_module /usr/lib/apache2-prefork/mod_proxy.so
It still working the same way.





I have a solution in my mind I expose it here for discard it because I whant to know if there exist another way.

FROM WHERE COME WHAT i THINK:

1) When I was "experimenting", I have added extra static IPs to my ethernet card, aside the already defined.
2) After I go to start -> system -> YaST contro center-> NET services -> DNS and names of PC and I have added simple names uno, dos, tres, ... to the extra IPs that I have assigned to my ethernet card. After that, I was able to access uno, dos, ... in my explorer without the need to type the static LAN IPs.

3) After the test and understand that those names are only visible for my computer [locally] (the other computers in the LAN wherent able to access them by name, because the names I hav gived where in my PC and not in the LAN, but I was able to access trought the extra static IPs for my ethernet card) I delete the extra IPs (was didactic) and also have deleted the names for those extra IPs in my computer.

THE SOLUTION:

1) Again assign extra static IPs to my ethernet card.
2) Isnt necesary put local names to those extra IPs.
3) Create as many forward-ports as new extra IPs starting for example from port 8081, 8082, ... and assigne each port for each new extra IP.
4) configure http.conf for check those local IPs.


I think that should work, but I dont whant to create new extra IPs for my ethernet card, because I think that is not the way of try to do VirtualHost.




------------------------

I dont know if the problem is that some1 and some2 are configured like "webhop" or redirects.

Quote:
some1.site.com -> original1.site.com:8080 -> MY.pub.lic.IP:8080

some2.site.com -> original2.site.com:8080 -> MY.pub.lic.IP:8080
That is like I see it ... I dont know if the problem is that when I enter to algo1 or algo2, they are the end point to the same address and port....



But in fact, that is what I wait to handle with apache and the control of virtual Host.

Last edited by hgb; 11-12-2005 at 12:31 AM.
 
Old 11-12-2005, 12:25 AM   #4
hgb
Member
 
Registered: Jun 2004
Distribution: Mandrake 10, SUSE 10.x, DEbian
Posts: 125

Original Poster
Rep: Reputation: 15
Hold on a moment, witht that explanation, I must say that

Quote:
some1.site.com -> original1.site.com:8080 -> MY.pub.lic.IP:8080

some2.site.com -> original2.site.com:8080 -> MY.pub.lic.IP:8080
in the apache conf, Im not trying to get someX.site.com, instead I have writed originalX.site.com

Quote:
<VirtualHost *>
ServerName original1.site.com
ServerAlias original1.*
DocumentRoot /apache_start/sites/some2
</VirtualHost>

<VirtualHost *>
ServerName original2.site.com
ServerAlias original2.*
DocumentRoot /apache_start/sites/some1
</VirtualHost>





----------------------------------------------------------------------

Quote:
If I remember correctly. The first vhost you define becomes the default by default.
Try to make that one empty. What concerns the both hosts returning the same site i don't know.

Just to eliminate things, try to have *:8080 instead of *
Yes, I have watched that "The first vhost you define becomes the default by default." when I rotate the virtual host for see if the change in something, and yes, if I put the "null" host, I get only the answer from the server, but with length=0 and sure no more data, if I rotate to the othervirtual host, then I get the other index.html from the other path.


"Just to eliminate things, try to have *:8080 instead of *", I will do that in a moment.


------------------------------------------------------------

oops, I guess my anterior drawing was uncorrect and unclear. Here is really how it is "mapped"


Code:
some1.site.com -> original1.site.com:8080
some2.site.com -> original2.site.com:8080

original1.site -> MY.pub.lic.IP
original2.site -> MY.pub.lic.IP

And that cause the flow like I guess it before:

some1.site.com -> original1.site.com:8080 -> MY.pub.lic.IP:8080
some2.site.com -> original2.site.com:8080 -> MY.pub.lic.IP:8080

Another more explicit explanation:


some1.site.com and some2.site.com are webhops or redirections, because I cant use port 80, and original1.site.com dosen't have a redirection service then it redirect them by default to port 80, is why I also use some1.site.com, because it can redirect that page to the other and append :8080 without you need to write it actually.

Code:
 some1.site.com -(webhop/redirect)-> original1.site.com:8080
some2.site.com -(webhop/redirect)-> original2.site.com:8080
 
original1.site -> MY.pub.lic.IP
original2.site -> MY.pub.lic.IP
 
MY.pub.lic.IP forward port 8080 -> 192.168.254.10
 
And that cause the flow like I guess is:
 
some1.site.com -> original1.site.com:8080 -> MY.pub.lic.IP:8080-> 192.168.254.10:8080
some2.site.com -> original2.site.com:8080 -> MY.pub.lic.IP:8080-> 192.168.254.10:8080

Last edited by hgb; 11-12-2005 at 02:09 AM.
 
Old 11-12-2005, 12:33 PM   #5
hgb
Member
 
Registered: Jun 2004
Distribution: Mandrake 10, SUSE 10.x, DEbian
Posts: 125

Original Poster
Rep: Reputation: 15
I get it.

The problem was, that I read somewhere that the name of the vitual host should be valid, I havent added them :S for the names of my computer .


Now, my two diferent pages with the two redirections are working as spected!!!!!


By the way, I also have noted a incorrect thing in my script, I miss change a thing :S... Im now going to change it now.
 
Old 11-14-2005, 02:14 PM   #6
Markild
LQ Newbie
 
Registered: Dec 2002
Distribution: Ubuntu
Posts: 16

Rep: Reputation: 0
Quote:
Originally posted by hgb
I get it.

The problem was, that I read somewhere that the name of the vitual host should be valid, I havent added them :S for the names of my computer .


Now, my two diferent pages with the two redirections are working as spected!!!!!


By the way, I also have noted a incorrect thing in my script, I miss change a thing :S... Im now going to change it now.
Great.. VirtualHosts can be a bit tricky at first, but when you got the up'n'running they're pretty awesome!
 
Old 11-20-2005, 10:35 AM   #7
boomy
LQ Newbie
 
Registered: Nov 2005
Location: Netherlands
Posts: 14

Rep: Reputation: 1
Quote:
Originally posted by hgb
I get it.

The problem was, that I read somewhere that the name of the vitual host should be valid, I havent added them :S for the names of my computer .


Now, my two diferent pages with the two redirections are working as spected!!!!!


By the way, I also have noted a incorrect thing in my script, I miss change a thing :S... Im now going to change it now.
Hi Hgb,
I don't know if you read this (it's more than a year ago). But I think I've got the same problem as you had.
Apache statistics says that I've configured 3 vhosts. And I've sniffed my network and do see the good requests from internet to the box.

I wanted: www.bougie.nu, ftp.bougie.nu, test.bougie.nu as different websites.
But Apache2 only uses the first vhost in the configuration. If I swap for example the last vhost as the first entry in the config. it uses still the first vhost.

I don't realy understand you sollution: "the name of the virtual host should be valid, I havent added them fot the names of my computer"
 
Old 11-22-2005, 07:51 PM   #8
boomy
LQ Newbie
 
Registered: Nov 2005
Location: Netherlands
Posts: 14

Rep: Reputation: 1
I got it.
for some strange reason you must fill in the <VirtualHost *> more completely.

so <VirtualHost *> becomes <VirtualHost 192.168.1.1:80>
or whatever your IP is.
After I did this everything worked! But as for all the documentation the * instead of the IPort has to work also, but doesn't.
 
Old 11-25-2005, 02:02 PM   #9
hgb
Member
 
Registered: Jun 2004
Distribution: Mandrake 10, SUSE 10.x, DEbian
Posts: 125

Original Poster
Rep: Reputation: 15
Quote:
I don't realy understand you sollution: "the name of the virtual host should be valid, I havent added them fot the names of my computer"
More than a year a go??? :S...

Anyway, I was refering that I have not make a alias or a valid name in my computer, you know, the default alias to 127.0.0.1 is localhost, then you can access http://localhost because localhost is a valid DNS name.

I have only added the alias of the names (I have aliased local host to: site1.domain.com, site2.domain.com, site3.domain.com), instead of put the IPs (like you do). And because they are now alias, they are valid DNS names in my PC.


Hope this help you and you uderstand it .
 
Old 11-25-2005, 02:09 PM   #10
boomy
LQ Newbie
 
Registered: Nov 2005
Location: Netherlands
Posts: 14

Rep: Reputation: 1
Quote:
Originally posted by hgb
More than a year a go??? :S...

My bad.. I've looked at the wrong date. the topic is not that old

I understand now how it works. But it also has to work with * instead of ip or dns.
Why it doesn't work with * or *:80 or *.* is a puzzle.
 
Old 01-24-2009, 02:05 AM   #11
jscarano
LQ Newbie
 
Registered: Jan 2009
Location: Denver, CO
Distribution: RHES5
Posts: 1

Rep: Reputation: 0
Apache VirtualHost Issues - httpd.conf configuration

FYI - I was troubleshooting the VirtualHosts section of the httpd.conf for several hours and was finally able to see my two different sites being hosted by one machine/ip by noticing the following:

1.) Startup error in error_log because of using *.80 instead of *:80
2.) Browser caching (need to clear cache, check with 2nd browser, etc.)
3.) My index.html files were the same (forgot to customize after copying)
4.) Added an extra section of VH descriptors (i.e. if you have 2 websites, you'll need 3 Virtual Host descriptor sections). The first VH section is generic and should just point to the main doc root (i.e. /var/www/html).
5.) Changed domain directory names (i.e from /domain1.com to just /domain1 - not sure this did anything, just listing all changes).
6.) Removed any .htaccess and index.html files from the main doc root (i.e. /var/www/html), and verified they were in the appropriate VH Doc Root subdirectories (i.e./var/www/html/domain1 and ~/domain2).

Hope this helps!

Red Hat ES 5
Apache 2.2

Last edited by jscarano; 01-24-2009 at 02:09 AM. Reason: further clarify
 
  


Reply

Tags
apache, conf, hosts, httpd, virtual


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
Apache2 Virtual Host SSI problems superscrappy Linux - Software 1 08-30-2005 05:04 PM
Apache2 virtual host cgi 403 Forbidden / mossy Linux - Software 15 07-27-2005 04:56 PM
apache2 help -Virtual Host- Fredstar *BSD 4 06-06-2005 01:09 PM
Can't do Apache2 virtual host different ports SK_pt Linux - Software 3 01-30-2005 07:04 PM
apache2, virtual host problems rjcrews Linux - Software 13 05-25-2004 08:16 PM


All times are GMT -5. The time now is 01:00 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration