LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 02-23-2012, 04:19 AM   #1
zasavage
Member
 
Registered: Sep 2010
Location: Bloemfontein , South Africa
Distribution: Slackware 13.37 and Slackware 14
Posts: 201

Rep: Reputation: 6
Apache and virtual host config


Hi there
I have 2 sites up on a virtual host .

My domains has A records for mail and www

when someone accesses mail.domain2.com it goes to domain1 root ..

How do I stop mail.domain1.com to access the http server .

Here is my conf of apache

NameVirtualHost *:80

<VirtualHost *:80>
ServerAdmin lawrence.mcdonald@domain1.com
ServerName www.domain1.com
DocumentRoot /var/www/htdocs/virt1
ServerAlias domain1.com
ErrorLog "/var/log/httpd/domain1_err_log"
CustomLog "/var/log/httpd/domain1_access_log" common
UseCanonicalName off
<directory /var/www/htdocs/virt1>
allow from all
</directory>
</VirtualHost>

<VirtualHost *:80>
ServerAdmin lawrence.mcdonald@domain1.com
ServerName www.domain2.com
DocumentRoot /var/www/htdocs/virt2
ServerAlias domain2.com
ErrorLog "/var/log/httpd/domain2_err_log"
CustomLog "/var/log/httpd/domain2-access_log" common
UseCanonicalName on
<directory /var/www/htdocs/virt2>
allow from all
</directory>
</VirtualHost>

regards
Lawrence

Last edited by zasavage; 02-23-2012 at 04:22 AM.
 
Old 02-23-2012, 05:14 AM   #2
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 244Reputation: 244Reputation: 244
Does it work without these ServerAlias directives (comment them and restart apache)
 
Old 02-23-2012, 05:37 AM   #3
zasavage
Member
 
Registered: Sep 2010
Location: Bloemfontein , South Africa
Distribution: Slackware 13.37 and Slackware 14
Posts: 201

Original Poster
Rep: Reputation: 6
@Cedrik

I commented alias out

Now mail and domain2.com goes to domain1.com

And www.domain1.com works as expected

Back to the drawing board


\
Lawrence
 
Old 02-23-2012, 06:51 AM   #4
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 244Reputation: 244Reputation: 244
Maybe comment out UseCanonicalName lines as well, but I think it is a dns issue
 
Old 02-23-2012, 07:55 AM   #5
zasavage
Member
 
Registered: Sep 2010
Location: Bloemfontein , South Africa
Distribution: Slackware 13.37 and Slackware 14
Posts: 201

Original Poster
Rep: Reputation: 6
@Cedrik

Commenting out canonical changed nothing


Lawrence
 
Old 02-23-2012, 08:02 AM   #6
dgrames
Member
 
Registered: Jul 2007
Distribution: Slackware
Posts: 152

Rep: Reputation: 50
Apache and virtual host config

Your ServerName should be domain1.com
ServerAlias should be www.domain1.com
 
Old 02-23-2012, 08:06 AM   #7
zasavage
Member
 
Registered: Sep 2010
Location: Bloemfontein , South Africa
Distribution: Slackware 13.37 and Slackware 14
Posts: 201

Original Poster
Rep: Reputation: 6
@dgrames

Swopped the name and aliases and
domain1.com is right and domain2.com
but mail.domain2 still ends up at domain1.com


Lawrence

Last edited by zasavage; 02-23-2012 at 08:08 AM.
 
Old 02-23-2012, 08:22 AM   #8
dgrames
Member
 
Registered: Jul 2007
Distribution: Slackware
Posts: 152

Rep: Reputation: 50
try changing NameVirtualHost *:80
to NameVirtualHost 192.168.1.50:80

does bind have a separate ip for mail.domain1.com

what does your httpd.conf have for the server name
 
Old 02-23-2012, 08:28 AM   #9
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
I'd definetly would set UseCanonialName to on on both vhosts. This makes for more robust self created URL's.
The Alias definition is just mere convenience which way you set it. Should'nt matter at all.

But like Cedric said check the DNS entries to see where those are pointing.
Code:
dig any www.domain1.com
dig any www.domain2.com
Don't read above but start here.
You don't have a configuration for mail.domain2.com so the server "redirects" to the default vhost which is domain1.com! Add an alias for mail inside domain2 and you'll be set.
 
Old 02-24-2012, 01:21 AM   #10
zasavage
Member
 
Registered: Sep 2010
Location: Bloemfontein , South Africa
Distribution: Slackware 13.37 and Slackware 14
Posts: 201

Original Poster
Rep: Reputation: 6
@zhjim

Thank you added another alias mail

That works , Thank you

Is there anyway that I can block access to mail and not www

Regards

Lawrence
 
Old 02-24-2012, 01:47 AM   #11
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
Remove mail alias and create an extra vhost for that domain then deny acces like this

Code:
Order DEny, Allow
Deny from ALL
inside the documentRoot configuration
 
Old 02-24-2012, 03:23 AM   #12
zasavage
Member
 
Registered: Sep 2010
Location: Bloemfontein , South Africa
Distribution: Slackware 13.37 and Slackware 14
Posts: 201

Original Poster
Rep: Reputation: 6
@zhjim

Thank you

Regards

Lawrence
 
  


Reply



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
Any way to tunnel apache virtual host to an internal apache? ciuly Linux - Server 5 01-31-2010 12:53 PM
Apache 2.0 virtual host config file mnm_mc Linux - Software 7 03-25-2006 10:57 PM
Apache named virtual host config darthtux Linux - Software 8 04-19-2005 02:38 AM
Apache: Virtual Host Config question rajanr Linux - Software 5 08-30-2003 12:41 PM
Virtual host config won't work klintonray Linux - Networking 18 08-19-2003 02:53 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 11:17 AM.

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