Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please point me in the right direction (or to the right forum) 1

Status
Not open for further replies.

wlwoman

Technical User
Jul 8, 2001
133
US
I am running Apache with RedHat 6.1 through a DSL connection. This works fine but allows me only one static IP and one domain name (zzzz.net). I would like to forward my other domain names (zzzz.com and zzzz.org) to this box but not have them show the primary domain (zzzz.net) in the location (address) bar. Is there a way to set up an alias or other whosie-whatsis so the sub-directory where I have these other domain names forwarded to will show the domain names I want (zzzz.com and zzzz.org) rather than the primary?

The more I do this, the more I realize how dumb I am when it comes to Linux! I have a Red hat Linux Bible but most of the time it doesn't tell me all the tricky little things I want to find out about....
 
Have you set up your virtual host entries for these
other domains? Is your dns configured correctly?
These are the two issues you will have to deal with.
Apache has good documentation on virtual hosting
and if you didn't know how to set up your dns then
you probably wouldn't be worrying about virtual hosts.
Generally you cname the virt.host domains.

Any specific issues, write back.
 
Hi wiwoman, haven't seen you in a while. If you have your main site up and running, this should be a peace of cake. You will need to have all your domains set up as vhosts. This means your main domain too. Set up vhost containers in httpd.conf that look something like this:

NameVirtualHost *

<VirtualHost *>

ServerAdmin webmaster@vhost1.com
ServerName UseCanonicalName Off
DocumentRoot /var/
<Directory &quot;/var/ Options All MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>

ScriptAlias /cgi-bin/ &quot;/var/
<Directory &quot;/var/ AllowOverride None
Options All
Order allow,deny
Allow from all
</Directory>

</VirtualHost>

Copy this then paste it 3 times to the bottom of httpd.conf and edit each one for each vhost. You would replace the &quot;vhost?&quot; with whatever you want to call each directory. The ServerName would be the real name of the domain. This is called name based addressing. The &quot;*&quot; says to listen for all addresses on all ports. The ServerName is what counts here. Next you need to set up dns to point the other 2 names the same way you got it to work for your main domain. You will use the same ip for all 3. Remember that these must be registered domain names.
 
Thank you! ! Those 60-hour weeks are killing my online time but I find a few minutes once in a while to work on the home front. I'm going to try your suggestion tomorrow and see what I get. It looks like what I tried to do but didn't quite make it.

All 3 domain names (.net, .org, and .com) are registered so hopefully this will work. I'll get back with the results. Thanks again!
 
Okay - I have edited my httpd.conf file but haven't uploaded it yet. Before I do, could you please review it and see if I need to change anything?
------------------------------------------
# ServerAdmin: Your address, where problems with the server should be
# e-mailed.

ServerAdmin webmaster@wwdnet.net
NameVirtualHost 65.187.228.169 ------>(or should this be the server name??????)

# BindAddress: You can support virtual hosts with this option. This option
# is used to tell the server which IP address to listen to. It can either
# contain &quot;*&quot;, an IP address, or a fully qualified Internet domain name.
# See also the VirtualHost directive.

BindAddress *


(then at the bottom....)


# UseCanonicalName: (new for 1.3) With this setting turned on, whenever
# Apache needs to construct a self-referencing URL (a url that refers back
# to the server the response is coming from) it will use ServerName and
# Port to form a &quot;canonical&quot; name. With this setting off, Apache will
# use the hostname:port that the client supplied, when possible. This
# also affects SERVER_NAME and SERVER_PORT in CGIs.

NameVirtualHost *

<VirtualHost *>

ServerAdmin webmaster@wwdnet.net
ServerName wwdnet.net
UseCanonicalName Off
DocumentRoot /home/ww1/www/

<Directory &quot;/home/ww1/ Options All MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>

ScriptAlias /cgi-bin/ &quot;/home/ww1/
<Directory &quot;/home/ww1/ AllowOverride None
Options All
Order allow,deny
Allow from all
</Directory>

</VirtualHost>

NameVirtualHost *

<VirtualHost *>

ServerAdmin webmaster@wwdnet.com
ServerName wwdnet.net
UseCanonicalName Off
DocumentRoot /home/ww1/
<Directory &quot;/home/ww1/ Options All MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>

ScriptAlias /cgi-bin/ &quot;/home/ww1/
<Directory &quot;/home/ww1/ AllowOverride None
Options All
Order allow,deny
Allow from all
</Directory>

</VirtualHost>

NameVirtualHost *

<VirtualHost *>

ServerAdmin webmaster@wwdnet.org
ServerName wwdnet.net
UseCanonicalName Off
DocumentRoot /home/ww1/
<Directory &quot;/home/ww1/ Options All MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>

ScriptAlias /cgi-bin/ &quot;/home/ww1/
<Directory &quot;/home/ww1/ AllowOverride None
Options All
Order allow,deny
Allow from all
</Directory>

</VirtualHost>
--------------------------------------------------
Thanks for your time. Hate to say I'm chicken when it comes to replacing critical files but......I'd like an expert to look first!
 
Hi wiwoman,
NameVirtualHost 65.187.228.169 ------>(or should this be the server name??????)

You only need NameVirtualHost defined once in httpd.conf. I like to keep it near where I have all my vhosts
defined. Using it with the &quot;*&quot; is ok, it means listen to all addresses on all ports. You also need to put each servers name in their containers. You have the same name in all of them. This would cause a bit of a problem when apache tries to resolve a name based address, wouldn't you think? :eek:)

DocumentRoot /home/ww1/www/
DocumentRoot /home/ww1/DocumentRoot /home/ww1/
You have the other two domains inside your first domain. This will work but it looks a little confusing. You also have ScriptAlias inside the DocumentRoot. This is reduntent because the alias is the same as the real directory and you have &quot;Options All&quot; which difines that directory as a script directory. Things will work like this too, but the usual way is to put your 3 websites inside &quot;home&quot;. For example /home/ww1, /home/ww2 and /home/ww3. Then put a DocumentRoot such as html or what ever and a cgi-bin, inside each of those. It will be a lot easier to admin that way but it's up to you. The only real problem I see with it not working is the same ServerName for all the name based vhosts.
 
Am I getting closer??????
----------------------------------
Deleted:

NameVirtualHost 65.187.228.169

and changed bottom portion to:


NameVirtualHost *

<VirtualHost *>

ServerAdmin webmaster@wwdnet.net
ServerName wwdnet.net
UseCanonicalName Off
DocumentRoot /home/ww1/www/

<Directory &quot;/home/ww1/ Options All MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>

ScriptAlias /cgi-bin/ &quot;/home/ww1/
<Directory &quot;/home/ww1/ AllowOverride None
Options All
Order allow,deny
Allow from all
</Directory>

</VirtualHost>


<VirtualHost *>

ServerAdmin webmaster@wwdnet.com
ServerName wwdnet.com
UseCanonicalName Off
DocumentRoot /home/ww2/www/

<Directory &quot;/home/ww2/ Options All MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>

ScriptAlias /cgi-bin/ &quot;/home/ww2/
<Directory &quot;/home/ww2/ AllowOverride None
Options All
Order allow,deny
Allow from all
</Directory>

</VirtualHost>


<VirtualHost *>

ServerAdmin webmaster@wwdnet.org
ServerName wwdnet.org
UseCanonicalName Off
DocumentRoot /home/wwd/www/

<Directory &quot;/home/wwd/ Options All MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>

ScriptAlias /cgi-bin/ &quot;/home/
<Directory &quot;/home/wwd/ AllowOverride None
Options All
Order allow,deny
Allow from all
</Directory>

</VirtualHost>

-------------------------------
One of these days I'll actually start to 'get it' ! Thanks for all your help :)
 
You're getting close. The directory structure below is my feeble attempt to show the directory tree:

/home/ww1/html
/cgi-bin
/ww2/html
/cgi-bin
/ww3/html
/cgi-bin

You don't have to use the original DocumentRoot. You are the boss and can have the DocumentRoot for each vhost any where on the drive you want it. It's standard practice to keep them in one place however.

Getting back to your httpd.conf file. It looks like it should work except for the last container. The ScriptAlias directory doesn't match the path in the directory container. Typo?
 
I forgot to answer you very first question. The forum you are looking for is Apache Group:Apache
 
Thank you - yes it was a typo (forgot the 'wwd') if that's the line you're talking about.

Since my directly is set up as /home/ww1/ the cgi-bin in the / I assumed that going with

/home/ww1/www
/cgi-bin
/home/ww2/www
/cgi-bin
/home/wwd/www
/cgi-bin

was logical. While the wwd might not seem logical, I already have the extra domain names pointed to those directories so I think I'll leave it.

With the typo fixed will it work?
 
yup - unless you have something else you ain't showing me. :eek:) ...and you have ALL your domains in vhost containers.
 
Yes sir I do! I guess it's time to try this file on for size... I'll let you know how it works as soon as I find out myself!
 
Oh, one more thing...since my 2 non-primary domains are being forwarded, how do I point them to the correct directory from the forwarder's end? Forwarder requires a valid URL, which would be my wwdnet.net addy.
 
I'm not sure what you mean by Forwading. Some DNS services provide WebForwarding as an extended service. Let's say your computer is gonna be down for a spell so you can add a new disk drive. You can put your html pages or a &quot;under consrtuction&quot; page in some free homepage you have on the internet. Then when someone requests it gets redirected by dns to or where ever you forward it to. If this is NOT what you are doing and your other 2 domains are registered, they each need their own DNS &quot;A&quot; record exactly like your first domain. Just edit each record to point to your ip. If you're not sure how to edit records directly, you can use a dns service such as and they have easy to use forms to edit your records for each zone. To make it simple, a zone is a main domain such as abc.com. to this you can add sub-domains such as mail.abc.com or username.abc.com etc. Zone edit lets you manage up to 5 zones for free. You can have as many sub-domains in each zone as you want. There are directions on how to switch to this service at their site. To answer your question, the url would be the &quot;ServerName&quot;. For example, and so on.
 
Okay - since I have identified each ServerName related to each unique domain name in each container, asking for my domain name forwarding to go to that particular ServerName should work.

I purchased my domain names and then 'parked' them until I was ready to point them to my server. In the old format, I had my wwdnet.com domain pointed to wwdnet.net/ww2/www/

In the new format, this would point to wwdnet.com - is this correct?

The later it gets in the day, the more inept I feel!

Thanks for your help - once again :)
 
Also, the forwarder will not allow me to forward my domain names to the same domain names; i.e. I cannot forward wwdnet.org to
 
shucks!!! Now you even have me confused. :eek:) You are talking about two different things here. Let's pretend your ip address is 123.45.67.8 and you have these three domains, wwdnet.com, wwdnet.org and wwdnet.net. Create a DNS &quot;A&quot; record and assign all three the ip address 123.45.67.8. For example assign the URL the IP 123.45.67.8 and before you know it, you should be able to type any of those addresses into your browser and it should come to your server. When it knocks on the door, apache will answer and look for that name in the virtual hosts. If one of the ServerNames matches, the request gets handed over to that virtual host. I hope I'm not confusing you more but in httpd.conf the ServerName is the domain name without the in DNS the domain is the is the domain with the www. I won't mess with your head by telling you that you can actually have an ip for wwdnet.com and a different one for These are almost always given the same IP. The path you were talking about in the container definitions doesn't have anything to do with DNS. These can point to anywhere on your drive as long as they correctly point to the file location.
 
Hi,



Do you mean url forwarding as provided by people like this -->


If so, I'd guess that involves mod_rewrite or equivalent at their end to rewrite the url to the address of the server its being forwarded to. In such cases, I don't imagine you could get vhosts to work because the original url would be overwritten.



Similarly, if you have a 'real' domain name that is being forwarded by someone, then there is probably no trace of the original domain part of the url by the time it reaches you. If its a 'real' domain (e.g. a .com, .net, .org or suchlike) then you'd have to go back to the place you registered that domain and get the DNS record changed (from their servers ?) to point at your IP address. If you have a static IP address for your main domain you just use the same IP address and apache chooses the correct virtual host based on the url. Otherwise, you'd have to use a DDNS service and post to that as and when your dynamic IP address changed.



Or, if you have a static IP then you can host your own DNS records with BIND.



Hope this helps
 
How about I send you my server and you send it back when it's done? :) Maybe I should take up parachuting instead?

I tried out the new httpd.conf file last night and then couldn't surf to the server at all. I renamed the files to replace the new one with the previous one. This is what my server said:

From my error_log:

[Mon Jan 21 22:31:36 2002] [notice] caught SIGTERM, shutting down
[Mon Jan 21 22:31:37 2002] [warn] _default_ VirtualHost overlap on port 80, the first has precedence
[Mon Jan 21 22:31:37 2002] [warn] _default_ VirtualHost overlap on port 80, the first has precedence
[Mon Jan 21 22:31:37 2002] [warn] NameVirtualHost *:80 has no VirtualHosts
[Mon Jan 21 22:31:37 2002] [notice] Apache/1.3.9 (Unix) (Red Hat/Linux) mod_perl/1.21 configured -- resuming normal operations
[Mon Jan 21 22:31:37 2002] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Mon Jan 21 22:37:03 2002] [notice] caught SIGTERM, shutting down
[Mon Jan 21 22:43:47 2002] [warn] NameVirtualHost 65.187.228.169:80 has no VirtualHosts
[Mon Jan 21 22:43:47 2002] [notice] Apache/1.3.9 (Unix) (Red Hat/Linux) mod_perl/1.21 configured -- resuming normal operations
[Mon Jan 21 22:43:47 2002] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)

The original domain seller allows me to modify the URL to any valid domain or IP number, so long as the URL I'm forwarding TO doesn't duplicate the domain name I'm forwarding. I tried changing my forwarding to send wwdnet.com to my IP address, which the forwarder accepted. Upon trying to access the server after the new httpd.conf was installed and the forwarding changed, I found that my browser couldn't locate the server.

On the server end, the provider has wwdnet.net registered as the domain name for my IP number. All the domain names are registered. The IP is static.


 
Hi,

Looks like its confused between IP and name based virtual hosts. Try removing the 'Bindaddress *' and replacing it with :

Listen 80
Listen 443

Also test your httpd.conf for syntax errors with :

/usr/sbin/httpd -t

(it should just say 'Syntax OK')

On the forwarding - It all depends how its done really. The name based virtual hosting facility in Apache works by the server examining the host: value in the http header of a client request and matching that with the various virtual host containers (i.e. the ServerName and ServerAlias directives therein). No match means that apache will arbitrarily choose the first one defined in httpd.conf. So, if the original url is and its rewritten as then thats fine it you have a virtual host for that latter name. However, if it rewrites it using an IP address e.g. - - then name based virtual hosts will not work because there is nothing to match on. In such a case, the first defined vhost will be selected by apache as the default, rightly or wrongly.

Regards
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top