Setting the server clock time and keeping it correct on ubuntu

by Jess Brown

I'm working on a university exam taking application and needed to make sure the clock on the server was properly set so students don't get upset that they didn't make the due date.

When I checked the server clock, it was correctly set for the time zone, daylight savings time and hour, but the minutes were off.

A couple of google searches talked about syncing the server with a server pool. That sounded pretty complicated, but time has to remain correct, right??

It actually turned out pretty simple. I used this blog article, but it boils down to a few easy steps:

sudo apt-get install ntp

Yep, that's it. You can change the config for the server pool if you like (see blog above), but that's pretty much it!

Simple Support for IE8 using Zurb Foundation 4

by Jess Brown

Recently I needed a quick easy way to support IE8 with foundation 4. I found a nice way and wanted to share it, check it out and let me know what you think.

Connecting Rails to Microsoft Exchange / SMTP Email Server

by Jess Brown

When a client first asked me to switch from Sendgrid to use their smtp exchange server, I figured it'd be really simple...like connecting to a gmail account. However, I ran into a few issues. Like a lot in programming, it wasn't anything way different than what I was doing, but a couple to syntax differences. Hopefully, someone will find find this helpful (surprisingly google didn't help me much with my searches).

So, here's the standard gmail setup:

config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
  :address        => 'smtp.gmail.com',
    :port           => '587',
    :authentication => :plan,
    :user_name      => ENV['SMTP_USERNAME'],
    :password       => ENV['SMTP_PASSWORD'],
    :domain         => 'brownwebdesign.com',
    :enable_starttls_auto => true
}

Just a few small changes below to the authentication type.

config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
  :address        => 'smtp.office365.com',
    :port           => '587',
    :authentication => :login,
    :user_name      => ENV['SMTP_USERNAME'],
    :password       => ENV['SMTP_PASSWORD'],
    :domain         => 'congrueit.com',
    :enable_starttls_auto => true
}

Your SMTP_USERNAME should be your whole email address.

The other thing that got me was you need to send from the actual account you're using to log in with. For example, don't send email from noreply@brownwebdesign.com and use support@brownwebdesign.com as your SMTP_USERNAME.

There may be some other setting on the exchange side that needs to be tweaked (smtp allowed, authentication, etc.), but I think my client had

Debugging

Maybe the more interesting this is how to debug it.

The app isn't in production yet, but I tried it on the production server first; didn't work. So, easy way never works. Try in test/dev first I use mailcatcher.me in development mode, so I took the smtp settings (above) from config/environments/production.rb and placed them in config/environments/development.rb

Then I made sure that config.action_mailer.raise_delivery_errors = false was set to true and that helped debug the reasons things were going wrong. I got an error about wrong authentication type and then that my account didn't have permission to send (was using different from address).

Setting Up A Godaddy Domain for Heroku

by Jess Brown

If you have a client using Godaddy, here's a quick tip for setting up a Godaddy domain for heroku.

 heroku domains:add www.example.com

That's easy enough to go into Godaddy's DNS manager and add a cname for www and link it to your heroku domain example.herokuapp.com.

But, heroku doesn't support naked domains (example.com). Some providers like DNSimple provide an alias for a naked domain. The next best thing is a forwarder. After setting up your CNAME record, exit out and find the link to turn forwarding on. Then, forward example.com to www.example.com (default is 301 permanent...you want that). Now you're good to go!

Setting Up SSL on Heroku

by Jess Brown

I really love Heroku. The simplicity and beauty of how it all works just makes me happy. However, unlike most of their instructions/documentation, I recently ran into a bit of trouble when setting up a custom domain ssl. Looking back on it, it wasn't all that big of a deal, but here's a few details in what I had to do to get it working.

First, know that you can always use heroku's free ssl with your-app.herokuapp.com, but if you want https://www.yourapp.com, you have to pay the $20/mo fee and setup the SSL Endpoint Add on.

I followed the directions here: https://devcenter.heroku.com/articles/ssl

Everything was heroku smooth until I got to the upload certificate part. Every time I tried to upload the certificate, I got an error. I've setup a few servers using ssl and felt pretty confident that I was using the right certificates/keys/etc. After a bit of trying and failing, and googling, I remembered in the last nginx server I setup for ssl I came across documentation for root certificates:

if you have a chain of certificates — by having intermediate certificates between the server certificate and the CA root certificate — they're not specified separately like you would do for Apache. Instead you'll need to concatenate all the certificates, starting with the server certificate, and going deeper in the chain running through all the intermediate certificates. This can be done with "cat chain.crt >> mysite.com.crt" on the command line. Once this is done there's no further use for all the intermediate certificates in what Nginx is concerned. You'll indicate in the Nginx configuration the file with all the (concatenated) certificates.

I decided to give it a try. I mostly use www.dnsimple.com for ssl certs ($20 bucks!) and they use RapidSSL. So I downloaded the rapidssl_bundle.pem file and concatenated it to the bottom of the server cert. Then heroku certs:add server.crt server.key worked just fine!

The other area I'm still a bit confused about is the "Configure DNS" section. You'll need to add (or change if you already have setup) your CNAME record to point to the new ssl endpoint add on that heroku creates when you successfully add your keys. What's not clear is if you still want to serve regular http traffic to certain parts of the app, does it still work?? The app I did this on we use https all the time, so it wasn't an issue, but I'm curious about the non https and how it works.

Update Matthew Manning @ Heroku was kind enough to read my article and answered my question. "Yes. A SSL endpoint can be used with both secure (https) and insecure (http) traffic." Thanks!

NOTE: It's been a few weeks since I ran into this trouble and now that I'm wring the blog article I wanted to try and recreate the error. My app still isn't live, and so as to avoid the $20 charge on another app, I just removed the keys and was going to try and re upload the cert only. It actually worked this time without the pem (no error). I'm not sure if this is because heroku still had something in cache or what?? However, even though it worked, when I previewed my certs heroku certs I got:

Endpoint                 Expires               Trusted
-----------------------  --------------------  -------
nara-2279.herokussl.com  2013-12-11 17:40 UTC  False</pre>

Only when I updated and used my concatenated cert did it work, so regardless of whether you get the error or not, you will need to cat the certs.

@mattmanning also gave me this advice: You might also want to mention the SSL Doctor client plugin, which can complete the chain of trust for you automatically. https://github.com/heroku/heroku-ssl-doctor


Navigation