Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
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
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????
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 *
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.
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
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"
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.
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.
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 03:09 AM.
Reason: further clarify
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.