Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > ISPConfig 2 > Tips/Tricks/Mods

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 28th April 2007, 12:32
radim_h radim_h is offline
Senior Member
 
Join Date: Jan 2007
Location: Prague, Czech
Posts: 426
Thanks: 34
Thanked 26 Times in 21 Posts
Send a message via ICQ to radim_h
Default user names as subdomains - HOWTO

I think this can interrest someone:

It used to drive me crazy have user names in format
http://www.domain.tld/users/webXX_user
wanted them as http://user.domain.tld (third level domain)

so here is how to do it

1. in Ispconfig go to Management->System Config->Settings->ISP manager
change User Prefix to [DOMAIN]_
then user dirs will lok like http://www.domain.tld/users/domain.tld_user

2. Create file /etc/httpd/user_rewrite.conf which includes

RewriteCond %{SERVER_NAME} !^www\.
RewriteCond %{SERVER_NAME} !^mail\. ( not neccessary see bellow)
RewriteCond %{SERVER_NAME} ^([^.]*)\.(.*\..*)$
RewriteRule ^/(.*)$ /var/www/www.%2/user/%2_%1/web/$1 [L]

You can create as many lines like "RewriteCond %{SERVER_NAME} !^www\." as you want
^www\. here means that www.domain.tld will not rewrite (will not be looking for directory http://www.domain.tld/users/domain.tld_www, but show www.domain.tld) In my case i'm using also rewrite to show webmail as mail.domain.tld for each domain so i also have
RewriteCond %{SERVER_NAME} !^mail\.

3. In ISP manager->sites click on your site, then go to "Co-domains" and add
yourIP * domain.tld

6 In ISPmanger->sites-> www.domain.tld ->Basic put "Include user_rewrite.conf" into Apache Directives (Optional):


If you have more domains and don't want to forget do this for each domain, change:
Management->Form Designer->Edit Form->isp - ISP Web:->edit->web_httpd_include->Edit and put Include user_rewrite.conf into Default: window

5. In DNS manager ->domain.tld-> records you must create
CNAME * domain.tld

6. probably not necessary, but you can restart apache "apachectl restart"

and you are done



=============
If you want to have mail.domain.tld for each domain showing your default webmail
must have in DNS for your site
CNAME mail yourwebmail.yourdomain.tld
and your /etc/httpd/user_rewrite.conf should look like this

RewriteEngine on
RewriteCond %{SERVER_NAME} ^mail.*.*$
RewriteRule .* /var/www/path_to_your_webmail_site/web$0 [L]
RewriteCond %{SERVER_NAME} !^www\.
RewriteCond %{SERVER_NAME} !^www2\.
RewriteCond %{SERVER_NAME} !^mysql2\.
RewriteCond %{SERVER_NAME} ^([^.]*)\.(.*\..*)$
RewriteRule ^/(.*)$ /var/www/www.%2/user/%2_%1/web/$1 [L]

It works for me, i have configured webmail outside ISPconfig apache, if you use some webmail inside ispconfig in /home/admispconfig/ispconfig/web/yourwebmail it may not work (haven't tried)






Just have 2 questions for Falco or some other developer here .)

1. is there more ellegant way how to include user_rewrite.conf for all domains?
It didnt work for me to include in httpd.conf for all domains at once, its working just when included for each Virtual Host separatelly

2. Can i change default DNS entry for domains without editing code?
In my case i like to have DNS for all domains by default like this:

A Record
empty (domain.tld is already included in zone file but not showed in DNS manager)

CNAME
Hostname Target
* mydomain.tld
mail mail.myhosting.tld

MX
Mailserver Hostname
mail.myhosting.tld
mailbackup.myhosting.tld

(by default it shows MX admin.myhosting.tld which is wrong for me i have admin on different ip adress then users webs)

Last edited by radim_h; 16th May 2007 at 19:46.
Reply With Quote
Sponsored Links
  #2  
Old 12th May 2007, 20:47
radim_h radim_h is offline
Senior Member
 
Join Date: Jan 2007
Location: Prague, Czech
Posts: 426
Thanks: 34
Thanked 26 Times in 21 Posts
Send a message via ICQ to radim_h
Default better one

rewrite thru http:// in previous post makes not neccessary overhead, better one will be rewrite on filesystem:

RewriteRule ^/(.*)$ /var/www/www.%2/user/%2_%1/web/$1 [L]



it should be nice to have it in /etc/httpd/conf/vhosts/Vhosts_ispconfig.conf
together with
AliasMatch ^/~([^/]+)(/(.*))? /var/www/webXX/user/$1/web/$3
AliasMatch ^/users/([^/]+)(/(.*))? /var/www/webXX/user/$1/web/$3
(btw: what are this aliases for?)

Is it possible to put it somewhere in the code to create rewrite automatically for each VirtualHost?

Last edited by radim_h; 12th May 2007 at 20:55.
Reply With Quote
  #3  
Old 13th May 2007, 19:53
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,752 Times in 2,582 Posts
Default

Quote:
Originally Posted by radim_h
(btw: what are this aliases for?)
Take a look at chapter 2.2.9 on http://ispconfig.org/downloads/manua..._src.htm#4_2_2 .

Quote:
Originally Posted by radim_h
Is it possible to put it somewhere in the code to create rewrite automatically for each VirtualHost?
You can modify the function make_vhost() in /root/ispconfig/scripts/lib/config.lib.php.
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #4  
Old 13th May 2007, 20:00
radim_h radim_h is offline
Senior Member
 
Join Date: Jan 2007
Location: Prague, Czech
Posts: 426
Thanks: 34
Thanked 26 Times in 21 Posts
Send a message via ICQ to radim_h
Default default aliases

I was just wondering, why you guys use this aliases
to make link http://www.domain.tld/users/testuser/
when user directory is var/www/webXX/user/
then you can show it as
http://www.domain.tld/user/testuser/ without rewrite.. ?
Reply With Quote
  #5  
Old 14th May 2007, 18:18
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,752 Times in 2,582 Posts
Default

Quote:
Originally Posted by radim_h
then you can show it as
http://www.domain.tld/user/testuser/ without rewrite.. ?
Yes, no rewrite is needed then.
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #6  
Old 14th May 2007, 19:43
radim_h radim_h is offline
Senior Member
 
Join Date: Jan 2007
Location: Prague, Czech
Posts: 426
Thanks: 34
Thanked 26 Times in 21 Posts
Send a message via ICQ to radim_h
Default .

So why it is in there? .o)
Reply With Quote
  #7  
Old 15th May 2007, 11:53
till till is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 37,022
Thanks: 840
Thanked 5,655 Times in 4,464 Posts
Default

Quote:
Originally Posted by radim_h
I was just wondering, why you guys use this aliases
to make link http://www.domain.tld/users/testuser/
when user directory is var/www/webXX/user/
then you can show it as
http://www.domain.tld/user/testuser/ without rewrite.. ?
I dont think that it will work without rewrite. The directory:

http://www.domain.tld/users/testuser/

is without rewrite:

/var/www/webXX/web/users/testuser/

and not:

/var/www/webXX/users/testuser/

The directory of the users is outside of the document root of the website.
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
  #8  
Old 3rd January 2008, 00:41
garymaurizi garymaurizi is offline
Junior Member
 
Join Date: Jan 2008
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default help!

how could i do this if webmail is in /home/admispconfig/ispconfig/web/roundcubemail/

It is outside of the document root. Using Mod_Rewrite seems to break roundcube & it wont login? & mail.anydomain.tld is not working for me?

I used the ispconfig update function to install roundcube, and it defaults to https://anydomain.tld:81/roundcubemail/index.php

I would like mail.anydomain.tld to use http on port 80 not https @ port 81, I've currently in user_rewrite.conf:

Quote:
RewriteEngine on
RewriteCond %{SERVER_NAME} ^mail.*.*$
RewriteRule .* /home/admispconfig/ispconfig/web/roundcubemail$0 [L]
RewriteCond %{SERVER_NAME} !^www\.
RewriteCond %{SERVER_NAME} !^www2\.
RewriteCond %{SERVER_NAME} !^mysql2\.
RewriteCond %{SERVER_NAME} ^([^.]*)\.(.*\..*)$
RewriteRule ^/(.*)$ /var/www/www.%2/user/%2_%1/web/$1 [L]

(user.anydomain.tld redirection does work fine).

I would like to be able to login @ both mail.anydomain.com && https://anydomain.tld:81/roundcubemail/index.php

perhaps there is a way to do something like this with user_rewrite.conf to forward 80 to 81@https for both security and client convienence also? Ive seen mod_rewrite and simmiliar forward port.

Last edited by garymaurizi; 3rd January 2008 at 01:08.
Reply With Quote
  #9  
Old 3rd January 2008, 16:08
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,752 Times in 2,582 Posts
Default

Quote:
Originally Posted by garymaurizi
how could i do this if webmail is in /home/admispconfig/ispconfig/web/roundcubemail/

It is outside of the document root. Using Mod_Rewrite seems to break roundcube & it wont login? & mail.anydomain.tld is not working for me?

I used the ispconfig update function to install roundcube, and it defaults to https://anydomain.tld:81/roundcubemail/index.php

I would like mail.anydomain.tld to use http on port 80 not https @ port 81, I've currently in user_rewrite.conf:




(user.anydomain.tld redirection does work fine).

I would like to be able to login @ both mail.anydomain.com && https://anydomain.tld:81/roundcubemail/index.php

perhaps there is a way to do something like this with user_rewrite.conf to forward 80 to 81@https for both security and client convienence also? Ive seen mod_rewrite and simmiliar forward port.
This might be interesting for you: http://www.howtoforge.com/apache_rev...roxy_ispconfig
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #10  
Old 3rd January 2008, 19:35
garymaurizi garymaurizi is offline
Junior Member
 
Join Date: Jan 2008
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Thanks falko

EDIT: Simple confusion, please see next post.

Last edited by garymaurizi; 3rd January 2008 at 20:47.
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Statistic not working mzo Installation/Configuration 49 20th April 2011 13:19
Anything I can do against illegal login-requests? schmidtedv Installation/Configuration 17 7th November 2008 10:25
Squirellmail and user names in "mail from ..." SkIRmiS Installation/Configuration 2 23rd October 2006 11:37
Mail Login, simple user names??? Kernal Panic Installation/Configuration 1 16th June 2006 03:45
User-name and subdomains for each user? (user@mydomain.com; user.mydomain.com) Pasco General 1 18th September 2005 20:35


All times are GMT +2. The time now is 05:25.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.