View Full Version : Self-Hosting Websites


quantumstate
09-09-09, 09:42 PM
Well my fifth (and last) web hoster has just collapsed into a steaming pile of schite like all the others, and I am sick of paying for (and hassling with) intermittent hosting.

So I used this guide (http://www.howtoforge.com/how-to-set-up-apache2-with-mod_fcgid-and-php5-on-debian-lenny) to set up Apache in a VirtualBox VM to serve my websites, and flanged port 80 through the wireless router for presentation to the outside.

BUT, when I went to set my registrar I tried to tell them that my dynamic IP is the new destination for my four websites. It gagged and said
26.26.202.116 was actualy not usable as DNS server. (try to add DNS glue record)
Hostname syntax error 26.26.202.116
WTF? Do I have to set up a DNS server to answer my registrar? Would dnsmasq be sufficient? I hate to do that for security reasons.

Has anyone set up their own hosting?

Next is email, and I am dreading it. Been without email for 3 days, and I'm sure my clients' emails are bouncing all over the place. Never wanted to, but it looks like I have to learn Exim.

ilovejedd
09-09-09, 09:57 PM
Use DynDNS? You can opt to use your own domain name. Forgot how much the custom DNS costs, though, but iirc, it was fairly reasonable.

By the way, how much traffic do you get and how fast is your internet connection? Also, is it a residential or business account? Just asking since hosting your own website is probably against your ISP's terms of service. Most business accounts don't have this limitation.

tux99
09-09-09, 11:16 PM
BUT, when I went to set my registrar I tried to tell them that my dynamic IP is the new destination for my four websites. It gagged and said

WTF? Do I have to set up a DNS server to answer my registrar? Would dnsmasq be sufficient? I hate to do that for security reasons.

Has anyone set up their own hosting?

Next is email, and I am dreading it. Been without email for 3 days, and I'm sure my clients' emails are bouncing all over the place. Never wanted to, but it looks like I have to learn Exim.

Do you have DNS services provided by your registrar or were you trying to change the authoritative DNS servers for your domain (that's what seems to me from your description)?

You can do web and email hosting from your dynamic IP (but it's far from ideal), but you certainly need a static IP to host your authoritative DNS servers (and at leat 2 of them).

For email server use Postfix, it's the most secure and fairly easy to configure.

Forgot to add: many providers block port 25 and port 80, check that first as you won't be able to host your own email and web servers with those ports blocked. Also dynamic IP are blacklisted on many mail servers therefore you need to use your ISP email server for outgoing mail, your own server would be usable only for inbound mail.

Your are in for a steep learning curve if you haven't done this before. :)

k_ross
09-09-09, 11:25 PM
You only need to change the A, CNAME, and MX records for your domains on the DNS servers. You don't need to change to different DNS servers.

quantumstate
09-10-09, 07:09 AM
ILJ, no one seems to have a comprehensive understanding on dynamic dns, nor how/why it would apply here. k_ross seems to offer a much more direct and simple solution. Seems like to pay for dyndns and my domain names would be double paying for the same thing.

tux, oh man. You're saying that inbound 25 & 80 might be blocked. Never thought of that, and I sure can't ask them without raising suspicion. My upload bandwidth will be fine for all but the multimedia on one website, but this is a residential account. (Queerwire) I don't know whether DNS services are provided by my registrar. All I know is I've always changed the authoritatives there. No idea of the mechanism. To use my ISP's email server for outbound it seems I'd have to use their domain, as most relaying is blocked for security reasons?

Kevin, I'm trying to understand what you're saying. So I can change the authoritative from my old (collapsed) hoster to the registrar, and modify some record on its DNS server? On my registrar it only allows me to specify the domain name, its DNS server, and "add a secondary DNS in our network".

But wait, in the top-level menu it has a choice to "define the content of your DNS (total control)"; Here it warns that my old DNS names will be replaced by nsa.{registrar}.com & nsb.{registrar}.com, and it asks for my webserver IP and mail server hostname. So I set the former to my dynamic IP and latter to mail.{domain}.com, and it says the request will be processed in a few minutes. Looks like this may be what I need, so now I need to test. Only thing is if it fails I won't know whether it's an Apache problem or a blocked port 80. Hm.

quantumstate
09-10-09, 07:49 AM
Holy crap. I set that for one of my websites and tried to access it normally, and lo and behold I got several firewall blocks on the VM guest's port 80! So I opened incoming 80 and tried again, and bingo:
Server error!
The server encountered an internal error and was unable to complete your request.
Error message:
Premature end of script headers: index.php
If you think this is a server error, please contact the webmaster (mailto:info@quantum-equities.com).
Error 500
www.quantum-equities.com
Thu Sep 10 05:27:08 2009
Apache/2.2.12 (Debian)
This is clearly an Apache setup problem, and I am in fact getting through all the layers to my server. tux you scared the sh*t out of me... although I suspect what you say is right more often than not.

quantumstate
09-10-09, 08:58 AM
OK something's knocked me onto Queer Street here. I got everything set for the first domain (mod_fcgi is very fussy about Rights and directories) and it seemed to have worked, but now I get nothing.

I've manually set my DNS record at my registrar to my dynamic IP, and it is showing up correctly in whois, but when I ping the domain it gives a completely different IP!

That doesn't make sense.

Edit: I see. When I re-set the IP to my dynamic it is correct for about 3 minutes, but then it gets set to some arbitrary IP address, I guess by some super master DNS server. WTH?

MichaelZ
09-10-09, 09:23 AM
It can takes hours and sometimes days for an IP change address to filter through the domains! Some master dns servers only update at night - this is why it is bad to use dynamic ip addresses. When your IP changes other DNS servers will continue sending the old cached address instead of the new one. When I've changed my IP which is very rare - I do it on the weekend since it make take up to two days for the new IP addy to get updated to all the DNS servers. I usually leave the old addy up during that time and relay to the new address.

quantumstate
09-10-09, 09:30 AM
No option to leave the old addy up, as my web hoster disappeared.

I know for it to fully propagate through the system can take days, but what doesn't make sense is that it changes for good use in seconds, and for a few minutes after I make the change it is correct. But then it's knocked out of whack to some arbitrary IP that I've never heard of before.

Oh sh*t, sure enough the bad IP is that of my old hoster. I guess it is a caching problem.

drkdiggler
09-10-09, 09:46 AM
I have been using www.easydns.com for several years, with a dynamic IP address, without issue. Their service costs $25 per year. If memory serves correctly, the only setup involves pointing your domain registrar to the easydns DNS servers. From there, you can use one of the many Dynamic DNS scripts that are available for linux to keep your IP up to date. I can't recall which one I am running, but if you are interested, I can check when I get home. The script that I am running checks my external IP address every few minutes using easydns's external IP address page (it uses www.whatismyip.com as the default), and then updates as needed.

These services are very useful not only for self-hosting (as I do with my blog) but also for setting up a VPN.

If you're curious, I run my blog on an OAMP stack (OpenBSD) within a virtual machine on my server. On that machine, Apache runs in a chroot jail. DMZ machines, such as my blog are all connected to a DMZ virtual switch that connects to my firewall via a separate NIC on my server, in an attempt to isolate them from my home network as much as possible. The firewall also has a separate NIC for DMZ connections.

zim2dive
09-10-09, 10:52 AM
I have been using www.easydns.com for several years, with a dynamic IP address, without issue. Their service costs $25 per year.

Yeah for a TLD you need to use one of the dynamic DNS services (all cost $$).

If you are content with a 2nd level domain, they are usually free.

Personally I have both a local website via a subdomain of dyndns, and then pay ~$50/year for hostmonster hosted service. The other benefit I get from this is that I use the mail servers at HM to relay my outgoing mail. As such I am freed from being locked in to an ISP service as my email (I can use fred@mydomain.com) as well as not using gmail (which would be free as well, but something just makes me nervous about them crawling all my email).. and I look at the HM email, web as a lazy man's backup.. ie. when I foobar my server at home, fetchmail doesn't run and the mail stays (and it readable) at HM.. ditto for my websites. At $100/year I might get motivated to move it all to my home server.. but pre-paying the year at HM... shrug. Keeps the load off what is also my HTPC.

PS. HM tech support seems to have reached new levels of clue-free recently, but the service has been mostly solid.

oaf
09-10-09, 11:20 AM
Hi

I've used Sitelutions (http://www.sitelutions.com/) for years. They offer a free DNS service and you can set the TTL low (helpful if your home IP address changes frequently). Your IP address can be set via their website or (automatically) using a script. I think they provide some "IP updater" example scripts but it's easy to write your own (I used Perl).

Hope this helps

Oaf

PS They also do backup MX so if your (e.g. self hosted) mail server goes down the mail will be picked up by them (and then picked up by "your" mailserver when it's back up). They have an annual charge for this but I was happy to pay a few dollars given the DNS service has worked so well. No connections with them (I'm in the UK) other than as a happy (free, then paying) customer.

quantumstate
09-10-09, 11:48 AM
Still no perspective on dyamic DNS services, but I am gathering from drkdiggler and zim2dive that they are a way-station between no domain and full-fledged domain.

I've always used a full-fledged registrar (bookmyname, France so out of reach of American law) and paid hoster-based operation with email built-in to the hosting service, all controlled through cPanel. I don't see the point of paying for a dyndns service and my registrar. Although dyndns does have automatic update of IP, due to DHCP caching (association of my MAC with a given IP) I generally keep the same IP for long periods of time, even through multiple reboot of my wifi router. When I want a different IP I always have to force it by changing my "MAC".

Time-to-live is an interesting function. May set that to 24 hours. And backup MX is a great idea. Hopefully my systems will be reliable enough to not need that much.

Whelp, time to tackle frickin' email...

quantumstate
09-10-09, 01:17 PM
I don't understand the email daemon. I've set it up and it's only listening on 25. So OK, I send an email out using my client and SMTP, so my mailserver is listening and gets it (where is it stored?), then forwards it to the destination server, wherever that is in the world. But is that forward done on 110? If so, when they send me an email and it comes in on 110, nobody's listening.

Exactly how is this supposed to work?

zim2dive
09-10-09, 01:50 PM
I don't understand the email daemon. I've set it up and it's only listening on 25. So OK, I send an email out using my client and SMTP, so my mailserver is listening and gets it (where is it stored?), then forwards it to the destination server, wherever that is in the world. But is that forward done on 110? If so, when they send me an email and it comes in on 110, nobody's listening.

Exactly how is this supposed to work?

You very likely will not be able to send mail directly from your home machine (on dynamic DNS via your ISP) out to the world.. the big guns out there (generally) will not accept mail from dynamic addrs as an anti-spam tactic. So you have to "relay" your outgoing mail thru your ISP or some other "approved" service.. in my case, I relay thru my webhost (hostmonster). Kinda like money-laundering :) altho HM (and presumably others) require authenticated relaying, so its not open to total abuse.

MichaelZ
09-10-09, 02:47 PM
I don't understand the email daemon. I've set it up and it's only listening on 25. So OK, I send an email out using my client and SMTP, so my mailserver is listening and gets it (where is it stored?), then forwards it to the destination server, wherever that is in the world. But is that forward done on 110? If so, when they send me an email and it comes in on 110, nobody's listening.

Exactly how is this supposed to work?

Your email server listens for all incoming mail on port 25 (unless encrypted). This is for both local and external mail. Port 110 is used by your email client that talks to your POP server and it retrieves the mail from your mail box. Your mail box location is dependent on where your email server puts it. To stop relaying you need to make sure no mail is received from someone NOT on your net that is resent to some other external mail server.

You can check out some setups for postfix here:
http://www.postfix.org/docs.html

k_ross
09-10-09, 04:48 PM
I've used ZoneEdit.com for years, which provides free DNS hosting (for the first 5 domains), and is very friendly to dynamic DNS updates. Install ddclient on Debian, and it will automatically update zoneedit whenever your IP address changes. The TTL will be set low, like 1 minute, so changes will propagate throughout the Internet very quickly.

For email, you'll want all outgoing mail to go through your ISP's mail server. If you're using Postfix, you can enable this functionality like so:

# cd /etc/postfix
# vi passwordmap

Add the following line:
hostname.of.your.isps.mailserver.com username:password

# chmod 600 passwordmap
# postmap passwordmap

# vi main.cf

Add the following lines:

relayhost = hostname.of.your.isps.mailserver.com
smtp_tls_security_level = encrypt
smtp_sasl_auth_enable = yes
smtp_sasl_tls_security_options = noanonymous
smtp_sasl_password_maps = hash:/etc/postfix/passwordmap

# /etc/init.d/postfix reload


This assumes your ISP requires authentication to send email through their server. Some don't. If they don't, then all you need is the "relayhost" line, forget everything else.

wnewell
09-11-09, 01:59 AM
Too much to read so if I dupe something, sorry. I've used no-ip.com for many years for dynamic dns starting when I first got DSL back around 2002. If you don't have a registered name, you can just create one with them using many of their default names. It's been totally free and has worked well for years. Now when I switched to fios I discovered that they blocked port 80, so one just needs to redirect it to a different port. You can either set your http software to listen on that port too or use your router or PC to translate it back to port 80. I've done it both ways, but prefer to do it in the router. They do charge a small fee if you have your own registered domain name and want them to provide DNS translation for that. If you need more info, ask.

mythmaster
09-11-09, 04:10 AM
How much extra is a business account with a couple of static IP's from your ISP? You could set up your own DNS as primary and use a public one as secondary in case of failure. It would save you tons of elbow grease and might be worth it. Granted, hosting your own web and email servers opens the door for a wide variety of attacks, so you are wise to run them in a VM.

quantumstate
09-11-09, 08:26 AM
Port 110 is used by your email client that talks to your POP server and it retrieves the mail from your mail box.
I know, but what POP server? All I have is instructions to set up SMTP. What is the relation between SMTP and POP servers, and why is there a difference? These fundamental questions seem to be unknown. I've tried setting up Exim as it's the one blessed by Debian, but I only get port 25. How can the Debian manual not go into this?! Time to try Postfix. I need email, like yesterday.

Thanks for the further advice on dynamic DNS, but I've got that beat. My IP has propagated now, and my websites are fully operational, thank God. Ya, on a dynamic IP, but I'll set TTL to say, 4 hours.

mm, I don't really trust Queerwire enough to step up to a business account. Had alot of signal problems. No other option but Crumcast here, and that's not an option. Considered security of course, and I'm not too worried about that. I'll cross that bridge when I come to it. Meanwhile, I'm incommunicado.

zim2dive
09-11-09, 08:41 AM
I know, but what POP server? All I have is instructions to set up SMTP. What is the relation between SMTP and POP servers, and why is there a difference? These fundamental questions seem to be unknown. I've tried setting up Exim as it's the one blessed by Debian, but I only get port 25. How can the Debian manual not go into this?! Time to try Postfix. I need email, like yesterday.

Ok, how are you wanting to:

- send mail
- receive mail
- and maybe it will be relevant, what mail client

they can be VERY different mechanisms depending on how you want stuff set up and how much you want to rely on outside machines/services.

Personally I run fetchmail and procmail to get/filter my mail (from multiple external sources) storing it locally (unread at this point). Then I run an imap server on the machine and can run Squirrelmail or Roundcube on the machine to serve up my own webmail.. or I can use whatever non-web IMAP mail client I chose, again connecting to my machine (currently I don't open that port outside my router tho, local only)

I use postfix to send outgoing mail, relayed thru my webhost (or could be your ISP), with SMTP authentication (required by my web host) to work around yahoo/gmail/etc rejecting outgoing mail from dynamic addrs.

Hopefully I didn't butcher any of that explanation.. I have set this up twice in the past 5 years.. each time requires a bit of cussing.. after which I have COMPLETE understanding of all of the above.. which I promptly bookmark and then FORGET.. by the time I need the info again, my memory os shot, the bookmarks have of course all expired :D and I have to start from scratch :D

EDIT1: I ended up using dovecot for my imap server b/c it was the easiest to make talk with Squirrelmail (plaintext or not plaintext passwords, etc)
EDIT2: links related to above (I had to skim these for parts that were relevant for me)
- debugging STMP AUTH : http://qmail.jms1.net/test-auth.shtml
- setting up a linux mail server: http://flurdy.com/docs/postfix/
- IMAP server debug: http://www.courier-mta.org/imap/tutorial.setup.html

quantumstate
09-11-09, 09:03 AM
I want all operations done locally, for global. I want my mailserver to send outgoing directly to the destination servers, and to receive incoming directly from them.

My ISP uses Google Apps mail, whatever that is. I hate Google for their atrocious privacy policy, however it seems they do not have purview over the Apps, and ostensibly cannot see or own mail transferred, as they do with GMail. I believe there are 10 free TLD email addresses you can register there, but for now I want to try as direct as possible and I am about to fail.

Interested in IMAP, but this is an emergency and POP will do. I've heard of Dovecot, but no idea what it all means.

zim2dive
09-11-09, 09:26 AM
I want my mailserver to send outgoing directly to the destination servers

Others may know better than I, but this is generally a fail for a residential acct b/c the destination servers generally will not trust mail coming from a known block of dynamic addrs. I had to set up relaying several years ago b/c of this, and then more recently had to upgrade the relay to be authenticated. I think you will have to relay thru whomever you hate least :D

quantumstate
09-11-09, 09:37 AM
Understand, I got this message before. But for now have to keep this as simple and direct as possible. Then (if I get stuff going) need to learn Google Apps and do what is necessary.

For now I gather that Cyrus is the POP/IMAP server I need, and I'm desperately following this (http://www.howtoforge.com/exim-mysql-cyrus-imapd-horde-centos5.1). How could the Debian manual not mention these pivotal aspects? And how can these idiots put up an Exim HowTo with no mention of POP/IMAP? Pffff...

zim2dive
09-11-09, 09:59 AM
Understand, I got this message before. But for now have to keep this as simple and direct as possible. Then (if I get stuff going) need to learn Google Apps and do what is necessary.

For now I gather that Cyrus is the POP/IMAP server I need, and I'm desperately following this (http://www.howtoforge.com/exim-mysql-cyrus-imapd-horde-centos5.1). How could the Debian manual not mention these pivotal aspects? And how can these idiots put up an Exim HowTo with no mention of POP/IMAP? Pffff...

I think I had trouble with cyrus vs. Squirrelmail as well.. so I ended up using dovecot for easiest (and possibly least secure) connection with Squirrelmail (also did some testing with Roundcube) I took the view that I didn't care WHICH server I used, just the one that made install the easiest and worked.. I tried uw-imap, cyrus, and dovecot.

note that most of the tutorials (such as the ones I linked and that you linked) also include lots more security than is technically required for getting a barebones set of connections up and going. They also may include more features than are needed (ie. Horde). I'm pretty sure my setup did not end up needing the mysql database either.

Personally I only install what I'm forced to (in this case for outgoing smtp auth). I'm pretty sure my head would have exploded following that CentOS server tutorial.

quantumstate
09-11-09, 10:20 AM
I was skeptical about Horde too, but it turns out that that's the mechanism you use to GUI set up virtual domains and user addresses, which I do need. These are stored in a MySQL database. The instructions seem straightforward, but nothing had better go wrong or else I'll have no idea what to do as there is absolutely no explanation.

Only adjustment from this CentOS tutorial is the method of installing files, and package names. Of course I had to infer some packages not mentioned or different-named to Debian. That may be my downfall, but I can always gas myself to death...

k_ross
09-11-09, 02:45 PM
I like Squirrelmail myself for webmail. I didn't like Horde+IMP, too bloated and slow for my liking. Roundcube is nice, but it doesn't have the big collection of plugins that Squirrelmail does. And since QS wants to use virtual email domains and users, Squirrelmail has plugins that let users change their password in MySQL, and manage Spamassassin settings, also stored in MySQL.

I also use virtual domains with my email setup. I've currently settled on Dovecot for my POP/IMAP server. It has good support for that. I've also used Courier IMAP, which is also good.

With regard to the Debian documentation, I just had a peek. The installation manual indeed does not mention POP or IMAP servers, and strictly speaking, they are not necessary for local users. A POP or IMAP server only becomes necessary when people want to retrieve email from over the net from your server. The Debian reference manual, in section 6 "Network Applications", does mention POP/IMAP servers, but just barely. It could definitely use some updating.

tux99
09-11-09, 05:16 PM
Until you get IMAP or POP running, you can read your mail directly from the mailspool on your mailserver with Pine too, no need for POP or IMAP.

Pine is actually a very nice fully featured mail client, I have been using it for 15 years or so, and don't see any reason to use anything else (I don't care about embedded graphics or similar multimedia crap in emails).

newlinux
09-11-09, 06:15 PM
I'm a pine (well, alpine now) user as well. works for me. I use postfix with authentication for outgoing mail through my ISP, and for my web site I use no-ip for dynDNS. I know I'm late to the party, but I thought I'd add my .5 cents. Been using no-ip for years with no problems. Recently just setup postfix again....

zim2dive
09-11-09, 06:26 PM
I'm a pine (well, alpine now) user as well. works for me. I use postfix with authentication for outgoing mail through my ISP, and for my web site I use no-ip for dynDNS. I know I'm late to the party, but I thought I'd add my .5 cents. Been using no-ip for years with no problems. Recently just setup postfix again....

If anyone needs source for elm, just lemme know :D I tried to upgrade to the 90's (ie. mutt) but never did :D

tux99
09-11-09, 06:30 PM
I'm a pine (well, alpine now) user as well. works for me.

Thanks for the pointer to Alpine, I didn't know Pine had now morphed into Alpine, I'm still using Pine 4.44 (from 2002!), LOL. It does all I need.

quantumstate
09-12-09, 08:05 AM
Thanks for the input on Squirrelmail and Dovecot Kevin. I always try to go with the Debian solution (Exim), and the only person I've found who seems to fully understand the emailing system uses Horde with Exim. I'm just trying to get it up right now.

It's been three frickin' days and my new IP still has not propagated through the DNS system. I do not understand this. It never, never took this long when I was using a hoster.

quantumstate
09-12-09, 09:47 AM
Looks like I'm going to fail. I have to infer so many things in the exim.conf.template file. exim is running with my changes, but what the functions are of the 30 sections, I simply do not have time to analyze and understand and therefore exactly where to put many of the changes. I still have Sunday morning to try at least, but that's all because I must work 12 hours/day 7 days/week. Haven't even had time to schedule my Myth HBO recording for the past couple of days.

Edit: OK here's my fatal error:
./exim4 restart
Stopping MTA for restart:2009-09-12 08:31:30 Exim configuration error in line 521 of /var/lib/exim4/config.autogenerated.tmp:
router local_delivery: cannot find router driver "lmtp"
Invalid new configfile /var/lib/exim4/config.autogenerated.tmp, not installing
/var/lib/exim4/config.autogenerated.tmp to /var/lib/exim4/config.autogenerated
Cyrus is installed and running, so I have no idea why the lmtp driver is not there. Cyrus is crucial.
I guess that's it. Exim has defeated me. No way I'll be able to complete a Postfix system config in a Sunday morning session of 2 hours.

tux99
09-12-09, 05:36 PM
I have no experience with exim, so unfortunately can't help you there.

No way I'll be able to complete a Postfix system config in a Sunday morning session of 2 hours.

Actually it took me only about an hour last time I did it (building from source and configuration), granted I have done it many times, but still postfix comes with a very reasonable and safe default config, it doesn't require many config changes, therefore it's fairly straightforward to set up.
There are plenty reasons why Postfix has replaced the previously most popular mail daemon, sendmail.

MichaelZ
09-13-09, 12:47 PM
I use postfix with courier imap/pop (both with ssl) and squirrelmail spamassassin, etc. Just use this guide:

http://flurdy.com/docs/postfix/

I used this to setup up my postfix server many years ago. It is still working great! I used maildir instead of mysql but I would probably do mysql today.

quantumstate
09-14-09, 10:01 AM
As my own dynamic IP never made it through DNS propagation, I can only conclude that the servers did not allow this. I checked the root server and it had it right, but not the lower-downs for some reason.

Signed up for MaxieHost yesterday ($9.99/year) and set DNS. All propagated today, and I was able to log into cPanel ONCE, before the whole webserver crashed. I guess this was a consequence of my setting my password. It's been down for over an hour now. No response from support, of course. Lost another day...