Apache Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsSystem AdministrationApache Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 18th, 2001, 06:20 PM
vboyz103 vboyz103 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2001
Posts: 14 vboyz103 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to vboyz103
Question Virtual Hosting again..

Hi, I am currently hosting some friends' web sites. I would like to have it look like http://username.mydomain.com instead of http://www.mydomain.com/~username through the use of public_html directory. By using username.mydomain.com, currently I have to add a virtual host tag like this:

<VirtualHost 1.2.3.4>
ServerName user1.mydomain.com
SeverAlias www.user1.mydomain.com
DocumentRoot /home/user1
</VirtualHost>

Then in the named zone file, I have to add an entry that would look like this:

user1 CNAME mydomain.com.

Or else it won't work when user1 try to access http://user1.mydomain.net.

and restart the named and apache server. This is ok, but a little bit of work. So my question is that if there are any way at all to do this dynamically through apache only but not through named.

Reply With Quote
  #2  
Old December 18th, 2001, 10:05 PM
freebsd freebsd is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Posts: 5 freebsd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
If you need a reply from me, first delete your 2 duplicated threads.

Reply With Quote
  #3  
Old December 18th, 2001, 10:42 PM
vboyz103 vboyz103 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2001
Posts: 14 vboyz103 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to vboyz103
I cannot delete threads

Sorry for the triple thread but it was accident...anyway, I do not have permission to delete thread. and I wish I could

Reply With Quote
  #4  
Old December 18th, 2001, 11:02 PM
freebsd freebsd is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Posts: 5 freebsd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Only moderator and original poster (you) can delete your own posts. First click on edit button, then check the checkbox on top where it says Delete, then click on Delete button.

Reply With Quote
  #5  
Old December 19th, 2001, 05:05 AM
freebsd freebsd is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Posts: 5 freebsd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Really, I expect to see those duplicated threads deleted so please don't disappoint me.

>> Then in the named zone file, I have to add an entry that would look like this: user1 CNAME mydomain.com.

If you read my reply in DNS forum, your dns part should be all set and good to go without a restart everytime adding a new user.

>> currently I have DocumentRoot /home/user1

Never set a docroot to the root directory of a user account as it's extremely insecure. Imagine visitors trying to reach http://user1.mydomain.com/.bashrc and reveal all private info you don't intend to. Instead, use the public_html directory approach but disable UserDir.

>> if there are any way at all to do this dynamically through apache

Say you have wildcard enabled in BIND, which is not so secure, you really should add each userX manually. As for Apache, you can use the directive VirtualDocumentRoot but I highly not recommend that because mod_vhost_alias is not very secure and its security record is very bad because of its design flaw problem. So instead, do something like so:

# Disabling UserDir
#LoadModule userdir_module libexec/apache/mod_userdir.so
#AddModule mod_userdir.c

<IfModule mod_userdir.c>
UserDir disabled
</IfModule>

# Turn this off
UseCanonicalName Off

# Set user to use public_html as his docroot
<Directory /home/*/public_html>
# Set default to None except FollowSymLinks
Options None +FollowSymLinks
# Now let them to use .htaccess to override your Options. Of couse, if you need to restrict them on something, disable such option
AllowOverride All
# Limit them to GET and POST, nothing else
<Limit GET POST>
Order allow,deny
Allow from all
</Limit>
<LimitExcept GET POST>
Order deny,allow
Deny from all
</LimitExcept>
</Directory>


# Here comes to mass vhost part
# Enabling mod_rewrite
RewriteEngine on

# Enabling Uppercase to lowercase conversion and assigning lc variable. Yes, you need this and I will explain later
RewriteMap lc int:tolower

# If requesting your defaultdomain, LAST it (stop going further)
RewriteCond %{HTTP_HOST} ^www\.mydomain\.com$ [NC]
RewriteRule ^(.+) - [L]

# Else if requesting ns1.mydomain.com or ftp.mydomain.com, [403] them
RewriteCond %{HTTP_HOST} ^([ns1|ftp]+)\.mydomain\.com$ [NC]
RewriteRule ^(.+) - [F]


# Else if requesting mydomain.com, LAST IT
RewriteCond %{HTTP_HOST} ^mydomain\.com$ [NC]
RewriteRule ^(.+) - [L]


# Else, all go here
RewriteCond %{HTTP_HOST} ^[^.]+\.mydomain\.com$ [NC]

# Skip images in /icons dir because it's reserved for global use, so skip those and save some server resources
RewriteRule ^/icons/(.+) - [PT,L]

# Assigning requested HTTP_HOST to $1 to be processed later
RewriteRule ^(.+) %{HTTP_HOST}=$1 [C]

# Converting HTTP_HOST to lowercase so http://UseR1.mydomain.com maps to the appropriate /home/user1/public_html directory
RewriteRule ^(.*)=(.*) ${lc:$1}$2 [C]

# Mapping host part to username and mapping REQUEST_URI to /home/username/public_html(here)
RewriteRule ^([^.]+)\.mydomain\.com(.*) /home/$1/public_html$2

# Next, set your IP
NameVirtualHost 12.34.56.78

# Set up just ONE <VirtualHost> block
<VirtualHost 12.34.56.78>
RewriteEngine on
RewriteOptions inherit
DocumentRoot "/www/htdocs"
ServerName www.mydomain.com
ServerAlias mydomain.com
ScriptAlias /cgi-bin/ /www/cgi-bin/
</VirtualHost>

Last edited by freebsd : December 19th, 2001 at 03:01 PM.

Reply With Quote
Reply

Viewing: Dev Shed ForumsSystem AdministrationApache Development > Virtual Hosting again..


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway