|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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. |
|
#2
|
|||
|
|||
|
If you need a reply from me, first delete your 2 duplicated threads.
|
|
#3
|
|||
|
|||
|
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 ![]() |
|
#4
|
|||
|
|||
|
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.
|
|
#5
|
|||
|
|||
|
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. |
![]() |
| Viewing: Dev Shed Forums > System Administration > Apache Development > Virtual Hosting again.. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|