Koozali.org: home of the SME Server

Web Hosting

Offline devtay

  • *
  • 145
  • +0/-0
Web Hosting
« on: June 17, 2011, 04:12:06 PM »
I am pleased to say my SME Server is working perfectly for my primary domain. I have a question about how to do hosting for websites.

I have read about virtual domains and tried setting this up using the domain panel and different settings (resolve locally or internet dns servers). Here is what I am doing.

Primary domain a.com hosted here mail and web works great.
Virtual domain b.com. only host web site no email, proxy, wpad, nada.

First try
Setup ibay to hold b.com.
Created b.com in domains with resolve locally. Changed internet dns records to point website to my public ip. Changed hostname email ip to point to where email is hosted (not on my SME box). Internet dns MX records point to where the email is hosted (not on my SME box). Send email from within domain, email returned or routed to local user with same username for primary domain. Website works great.

Second try
Delete everything.
Setup ibay to hold b.com
Created b.com in domains with internet dns servers. Changed internet dns records to point website to my public ip. Internet dns records point to current mx (not on my SME box). Send email from within domain, email returned or routed to local user with same username for primary domain. Website works great.

This server used to forward all email traffic to another local server that I setup using the email panel in server manager (address of local email server). I changed it back when I upgraded and all is good. It may be that this setting could affect what I want, but it would do it for all domains on the server.

I read about sitemaker and I am not certain this is what I need to do. I don't want to install the contrib if it won't do what I want because I have to reboot the server and it's in production. All I need to figure out is how to keep the primary domain exactly the same and add a Apache function for hosting the site only on the secondary/virtual./b.com domain. The sitemaker seems to do something close to this but I am not sure.

Looking for advice. The reason I am needing to do this is we currently pay a hosting company to host the site. A different company hosts the email. Everything works, but I think we should be able to host the website here and reduce the cost. I know I can host the email too, but my server and connections won't handle the email volume for both my primary and the virtual domain I am trying to create.

All of the searches on the forums I have been doing don't return what I am looking for so either I am typing the wrong terms in or no one else has wanted to do this. Any advice out there?
You can't stop what's coming. It ain't all waiting on you.

Online mmccarn

  • *
  • 2,653
  • +10/-0
Re: Web Hosting
« Reply #1 on: June 18, 2011, 02:39:14 PM »
You could configure b.com to forward all email to the real, off-site mailserver: http://wiki.contribs.org/Email#Deliver_email_for_one_domain_to_an_internal_mail_server  Someone tested this about a month ago and said it works with off-site servers in 7.5.1.

What I usually do, however, is to *not* create a domain for "b.com", but instead create a local domain for "www.b.com".  Then, the web server responds as "www.b.com", but the SME does not intercept email for "...@b.com". If your SME must respond to web queries at "http://b.com", I would then solve that problem using custom template fragements.

Offline devtay

  • *
  • 145
  • +0/-0
Re: Web Hosting
« Reply #2 on: June 18, 2011, 03:13:36 PM »
mmccarn,

Quote
You could configure b.com to forward all email to the real, off-site mailserver: http://wiki.contribs.org/Email#Deliver_email_for_one_domain_to_an_internal_mail_server  Someone tested this about a month ago and said it works with off-site servers in 7.5.1.

This is the missing piece of the puzzle. Thanks for pointing this out to me. I was looking at doing a custom template for my httpd.conf file but this may just fix my issue. I will try this and report back with the results in case someone else needs this in the future. Thanks again.
You can't stop what's coming. It ain't all waiting on you.

Offline devtay

  • *
  • 145
  • +0/-0
Re: Web Hosting
« Reply #3 on: June 20, 2011, 05:48:41 PM »
I needed the webserver to respond to external requests and don't know exactly how to get the custom-template to work as you described in your original reply. I assume look at the httpd.conf file then create a custom template in /etc/e-smith/templates-custom/etc/httpd/conf/http.conf to handle an entry for b.com.

What I did was your first suggestion. I made the necessary changes to internet DNS and added a new b.com domain. I issued the commands outlined in the document you linked to.  Everything seemed to be working fine, but after the first test email I soon received an email from my server saying: 450 Unable to connect to xxx.xx.xxx.xx: Operation now in progress. Only one of 4 test emails went through, so it's possible the email hosting company is blocking the connection. Since I made the change to the way the email server works for b.com I thought it a good idea to check the log files. qmail log shows no information for the test messages. the qpsmtpd log shows the information below which proved my first thought on the failure wrong.

2011-06-20 10:11:17.493914500 30217 Accepted connection 0/40 from 192.168.xxx.xxx / xx.xxx.com
2011-06-20 10:11:17.494046500 30217 Connection from xxxx.xxx.com [192.168.xxx.xxx]
2011-06-20 10:11:17.496816500 30217 tls plugin (init): ciphers: ALL:!aNULL:!ADH:!eNULL:!LOW:!EXP:RC4+RSA:+HIGH:+MEDIUM
2011-06-20 10:11:17.504879500 30217 220 xx.xxxx.com ESMTP
2011-06-20 10:11:17.505332500 30217 dispatching EHLO xxxxxxxxxxxx
2011-06-20 10:11:17.506526500 30217 250-ftav.com Hi xxxxxx.xxxx.xxxx [192.168.xxx.xxx]
2011-06-20 10:11:17.506543500 30217 250-PIPELINING
2011-06-20 10:11:17.506566500 30217 250-8BITMIME
2011-06-20 10:11:17.506589500 30217 250-SIZE 10000000
2011-06-20 10:11:17.506610500 30217 250 STARTTLS
2011-06-20 10:11:17.507039500 30217 dispatching MAIL FROM: <xxxx@xxxx.com>
2011-06-20 10:11:17.507240500 30217 full from_parameter: FROM: <xxxx@xxxx.com>
2011-06-20 10:11:17.508466500 30217 getting mail from <xxxx@xxxx.com>
2011-06-20 10:11:17.508503500 30217 250 <xxxx@xxxx.com>, sender OK - how exciting to get mail from you!
2011-06-20 10:11:17.508812500 30217 dispatching RCPT TO: <xxxxx@xxxxx.com>
2011-06-20 10:12:17.508553500 30217 logging::logterse plugin (deny): ` 192.168.x.xxx   xxxx.xxxx.com   xxxx   <xxxx@xxxx.com>      check_smtp_forward   902   Unable to connect to xxx.xxx.xxx.xxx: Operation now in progress   msg denied before queued
2011-06-20 10:12:17.508648500 30217 450 Unable to connect to xxx.xxx.xxx.xxx: Operation now in progress
2011-06-20 10:13:35.012106500 30217 dispatching QUIT
2011-06-20 10:13:35.012257500 30217 221 xxxx.xxx closing connection. Have a wonderful day.
2011-06-20 10:13:35.012294500 30217 click, disconnecting
2011-06-20 10:13:35.673124500 4737 cleaning up after 30217

I think this is saying the qpsmtp plugin check_smtp_forward is killing the message before the connection is made to the remote email server. I don't want to change the qpsmtpd spam checks, so I think I am going to have to go the route of a custom template fragment with a local domain setup.

Since using the server-manager panel to create a local host also creates ftp, mail, wpad and proxy in the hostnames panel, I assume you delete these entries after they are created to get the mail server to ignore b.com email. Next, I will have to change a template. I started looking at the httpd.conf file to see where I would need to insert data. I am assuming I will be changing the <virtualhosts></virtualhosts> section for b.com.

Do you think I going in the right direction? Can you offer your guidance or post an example of how you did the custom template?
You can't stop what's coming. It ain't all waiting on you.

Online mmccarn

  • *
  • 2,653
  • +10/-0
Re: Web Hosting
« Reply #4 on: June 21, 2011, 02:15:25 PM »
I issued the commands outlined in the document you linked to.  Everything seemed to be working fine, but after the first test email I soon received an email from my server saying: 450 Unable to connect to xxx.xx.xxx.xx: Operation now in progress.
Code: [Select]
2011-06-20 10:12:17.508553500 30217 logging::logterse plugin (deny): ` 192.168.x.xxx xxxx.xxxx.com xxxx <xxxx@xxxx.com> check_smtp_forward 902 Unable to connect to xxx.xxx.xxx.xxx: Operation now in progress msg denied before queued

I think this is saying the qpsmtp plugin check_smtp_forward is killing the message before the connection is made to the remote email server. I don't want to change the qpsmtpd spam checks, so I think I am going to have to go the route of a custom template fragment with a local domain setup.

I suspect your ISP's mail server doesn't like the way 'check_smtp_forward' verifies recipient email addresses.  From the error message, it sounds like the limit could be on the number of simultaneous connections with a single (your SME's) IP address.

In any case, if your SME's web server is currently configured correctly (responding from offsite to queries for b.com with the correct content), I would:
* Open /etc/httpd/conf/httpd.conf
* Locate the content related to the virtualhost for b.com. There should be two sections - one for http (<VirtualHost 0.0.0.0:80> and another for https (<VirtualHost 0.0.0.0:443>)
* Copy that content into a custom httpd template fragment named /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf/81Virtual_b.com
* Delete the SME domain entry for b.com

[wild guess]
Or, if you're feeling adventurous and need to setup multiple domains like your b.com with web access but no email, you could
  • delete b.com from the SME domains
  • duplicate the template fragment /etc/e-smith/templates/etc/httpd/conf/httpd.conf/80VirtualHosts as /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf/81VirtualWebHosts
  • Edit /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf/81VirtualWebHosts, changing the "type" lookup on line 18 from 'type' => 'domain' to 'type' => 'webdomain'
  • Manually create "webdomain" entries in the domains db as follows:db domains set b.com webdomain Content b-ibay Description Test Nameservers internet
    • b.com is your domain name
    • "webdomain" must match exactly the text you entered into 81VirtualWebHosts
    • "Content" is a field name, and must be exactly this, including capitalization
    • "b-ibay" is the ibay name that contains the web content for b.com
    • "Description" is a field name, and must be exactly this, including capitalization
    • "Test" is the description for this domain.  I recommend that you avoid having any spaces in the description.
  • rebuild httpd.conf using expand-template /etc/httpd/conf/httpd.conf
  • restart httpd.conf using sv restart httpd-e-smith

If this works, you could create additional future "web only" domains simply by repeating the last 3 steps.

If it doesn't work, you can remove all traces of these modifications using
  • db domains delete b.com
  • rm -f /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf/81VirtualWebHosts
  • expand-template /etc/httpd/conf/httpd.conf
  • sv restart httpd-e-smith
[/wild guess]

[edit]
db delete changed to db domains delete as pointed out by unnilennium
[/edit]
« Last Edit: June 22, 2011, 01:00:39 PM by mmccarn »

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Re: Web Hosting
« Reply #5 on: June 21, 2011, 02:31:02 PM »
I suspect your ISP's mail server doesn't like the way 'check_smtp_forward' verifies recipient email addresses.

No, that's not what it's saying. It's saying that it cannot create an SMTP connection. I'd suspect that the ISP is blocking port 25 outbound. OP will need to relay via the ISP's SMTP server.

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Re: Web Hosting
« Reply #6 on: June 21, 2011, 02:36:13 PM »
Or, if you're feeling adventurous and need to setup multiple domains like your b.com with web access but no email, you could
  • delete b.com from the SME domains
  • duplicate the template fragment /etc/e-smith/templates/etc/httpd/conf/httpd.conf/80VirtualHosts as /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf/81VirtualWebHosts
  • Edit /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf/81VirtualWebHosts, changing the "type" lookup on line 18 from 'type' => 'domain' to 'type' => 'webdomain'
  • Manually create "webdomain" entries in the domains db as follows:db domains set b.com webdomain Content b-ibay Description Test Nameservers internet
    • b.com is your domain name
    • "webdomain" must match exactly the text you entered into 81VirtualWebHosts
    • "Content" is a field name, and must be exactly this, including capitalization
    • "b-ibay" is the ibay name that contains the web content for b.com
    • "Description" is a field name, and must be exactly this, including capitalization
    • "Test" is the description for this domain.  I recommend that you avoid having any spaces in the description.
  • rebuild httpd.conf using expand-template /etc/httpd/conf/httpd.conf
  • restart httpd.conf using sv restart httpd-e-smith

If this works, you could create additional future "web only" domains simply by repeating the last 3 steps.

If it doesn't work, you can remove all traces of these modifications using
  • db delete b.com
  • rm -f /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf/81VirtualWebHosts
  • expand-template /etc/httpd/conf/httpd.conf
  • sv restart httpd-e-smith

This looks like a good suggestion to me.

Description can contain spaces, as long as quotes (single or double) are used on the command line.
« Last Edit: June 21, 2011, 02:38:03 PM by CharlieBrady »

Offline Jean-Philippe Pialasse

  • *
  • 2,912
  • +11/-0
  • aka Unnilennium
    • http://smeserver.pialasse.com
Re: Web Hosting
« Reply #7 on: June 21, 2011, 03:34:25 PM »
This looks like a good suggestion to me.

Description can contain spaces, as long as quotes (single or double) are used on the command line.

Perfect except a typo :
Code: [Select]
db delete b.comshould be read

Code: [Select]
db domain delete b.com
Shall we insert this in the wiki ?

JP

Offline devtay

  • *
  • 145
  • +0/-0
Re: Web Hosting
« Reply #8 on: June 21, 2011, 03:50:34 PM »
This looks like a good suggestion to me.

Description can contain spaces, as long as quotes (single or double) are used on the command line.

mmccarn, charlie and unnilennium,

The quote didn't copy over very well, but I am going to try this today and see what I get. Will report back when I'm done. I will copy the commands over exactly as I type them in putty so we will have them if this goes in the wiki (great idea btw). Thanks so much for the help.

D
You can't stop what's coming. It ain't all waiting on you.

Offline devtay

  • *
  • 145
  • +0/-0
Re: Web Hosting
« Reply #9 on: June 21, 2011, 06:16:04 PM »
Seems to be a good fix. Here is what I did:
Code: [Select]
cp /etc/e-smith/templates/etc/httpd/conf/httpd.conf/80VirtualHosts /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf/81VirtualWebHosts

pico 81VirtualWebHosts (to edit type to webdomain leaving the syntax of the file the same)

db domains set b.com webdomain Content actualibayname Description descriptionofsite Nameservers internet

expand-template /etc/httpd/conf/httpd.conf

sv restart httpd-e-smith (I received a normally down message so I did the next for good measure).

/etc/init.d/httpd-e-smith restart

sv restart tinydns

signal-event dns-update


Actually, I messed up the db domains statement and had to delete a property I misspelled. The second time around I did it right though. :lol:

I changed the Internet DNS and had to force the tinydns update (last two commands above) and do
Code: [Select]
ipconfig /flushdnson my local pc as well.

Checked configuration with
Code: [Select]
db domains show and all of the properties/keys that were added are shown correctly.

I also tested email and no problems there. The server is correctly processing email and handing off to the remote server.

On a side note, while messing around in the httpd.conf file, I found some interesting stuff. The phpsysinfo was especially nice to get to.

I'm not trying to hijack this thread or anything. My newly created domain doesn't show up on my web statistics panel (awstats contrib). I may just try a remove and install on this contrib again and see what happens.

Thanks again for all of the help.
You can't stop what's coming. It ain't all waiting on you.

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Re: Web Hosting
« Reply #10 on: June 21, 2011, 06:30:18 PM »
My newly created domain doesn't show up on my web statistics panel (awstats contrib). I may just try a remove and install on this contrib again and see what happens.

That would just be a waste of your time. The awstats contrib would need to be modified to be made aware of 'webdomain' records in the domains db.

Offline devtay

  • *
  • 145
  • +0/-0
Re: Web Hosting
« Reply #11 on: June 21, 2011, 06:42:28 PM »
Ok. Thanks. I will just leave it alone then. Appreciate the help.
You can't stop what's coming. It ain't all waiting on you.

Offline devtay

  • *
  • 145
  • +0/-0
Re: Web Hosting
« Reply #12 on: June 24, 2011, 11:37:34 PM »
This is still working except when I type www.b.com in the browser apache serves a.com. If I type in b.com, apache serves b.com. I traced the problem to the ServerAlias under b.com in the httpd.conf file. If I edit the httpd.conf file and put www.b.com in the ServerAlias everything works. That means I need a custom template adjustment to add www.b.com to ServerAlias. I tracked the ServerAlias portion of my primary domain to the template in /etc/e-smith/templates/etc/httpd/conf/httpd.conf/VirtualHosts/03ServerAlias. After reading the file, I am not so sure a custom template fixes this. If I'm reading this right (which I may not be) I need to add a db entry for the 'HostType' for b.com. Just like the custom template fix we did for the webdomain.

I looked at http://bugs.contribs.org/show_bug.cgi?id=6437 for 8.0 and I am more confused. Can anyone shed some light on this issue for me?
You can't stop what's coming. It ain't all waiting on you.

Offline devtay

  • *
  • 145
  • +0/-0
Re: Web Hosting
« Reply #13 on: June 25, 2011, 12:49:09 AM »
Ok. I figured it out I think. The reason why www.b.com wasn't working is because it wasn't defined in the hosts file (/etc/hosts/hosts.conf). When the template for /etc/httpd/conf/httpd.conf was expanding, the perl script would not find the entry for www.b.com therefore it would not show up in the httpd.conf file when /etc/e-smith/templates/etc/httpd/conf/httpd.conf/VirtualHosts/03ServerAlias looked through the configuration database for it. I didn't fix this by going to the server-manager but by using the command prompt. Here is what I did, I hope it's ok because it seems to be working.

1. Look through the hosts file with db hosts show | grep b.com (no entries were found because it wasn't created with the domains panel in server manager).
2. Figure out what properties were needed by using db hosts show | grep a.com (a.com being the primary domain).
3. Make entries into the hosts database by issuing db hosts set www.b.com host HostType Self
4. Expand template with expand-template /etc/hosts followed by signal-event host-create
5. Expand apache template with expand-template /etc/httpd/conf/httpd.conf
6. Restart apache (I do both) sv restart httpd-e-smith restart and /etc/init.d/httpd-e-smtih restart

Now when I go to www.b.com or b.com I get the correct virtual host. The a.com and www.a.com addresses remain unaffected and the virtual hosts section of b.com for port 80 and 443 both contain the ServerAlias entry www.b.com.

Please correct my terms and understanding if I missed something.
You can't stop what's coming. It ain't all waiting on you.

Offline devtay

  • *
  • 145
  • +0/-0
Re: Web Hosting
« Reply #14 on: August 22, 2011, 08:29:49 PM »
This worked for quite a while but I recently had to redo these steps. When I looked for the host in the hosts file it was gone. Any idea why the server is dropping this configuration?

Quote
Ok. I figured it out I think. The reason why www.b.com wasn't working is because it wasn't defined in the hosts file (/etc/hosts/hosts.conf). When the template for /etc/httpd/conf/httpd.conf was expanding, the perl script would not find the entry for www.b.com therefore it would not show up in the httpd.conf file when /etc/e-smith/templates/etc/httpd/conf/httpd.conf/VirtualHosts/03ServerAlias looked through the configuration database for it. I didn't fix this by going to the server-manager but by using the command prompt. Here is what I did, I hope it's ok because it seems to be working.

1. Look through the hosts file with db hosts show | grep b.com (no entries were found because it wasn't created with the domains panel in server manager).
2. Figure out what properties were needed by using db hosts show | grep a.com (a.com being the primary domain).
3. Make entries into the hosts database by issuing db hosts set www.b.com host HostType Self
4. Expand template with expand-template /etc/hosts followed by signal-event host-create
5. Expand apache template with expand-template /etc/httpd/conf/httpd.conf
6. Restart apache (I do both) sv restart httpd-e-smith restart and /etc/init.d/httpd-e-smtih restart

Now when I go to www.b.com or b.com I get the correct virtual host. The a.com and www.a.com addresses remain unaffected and the virtual hosts section of b.com for port 80 and 443 both contain the ServerAlias entry www.b.com.

Please correct my terms and understanding if I missed something.
You can't stop what's coming. It ain't all waiting on you.