Posts

Showing posts from May, 2010

Overcomming the virtual hosts/HTTPs conflict on Amazon AWS

Previously I've described the conflict between virtual hosts and HTTPs. For those that use Amazon's EC2 cloud, the below describes an elegant remedy for that conflict .

Assumed Basic Setup
For the purposes of this example, I'll assume you have an EC2 instance of Ubuntu Lucid with an apache server serving two websites: example.com and eazybusiness.com. Both have their own virtual host definitions, each containing it's corresponding site's specific configuration. If you need more information on how to configure your virtual hosts I direct you to apache's comprehensive documentation on the subject.

The virtual host definitions would look something like:

<VirtualHost *:80>
ServerName www.eazybusiness.com

ServerAdmin admin@eazybusiness.com
DocumentRoot /var/sites/eazybusiness.com/
</VirtualHost>
<VirtualHost *:80>
ServerName www.example.com

ServerAdmin admin@example.com
DocumentRoot /var/sites/example.com/
</V…

Multiple HTTPs websites on one webserver

A long time ago, servers were very slow and a web server could only handle one web site. In time, increased computing power and virtual hosts technology allowed one webserver to handle multiple web sites. At the same time as websites started to share the one webserver, HTTPS was coming to the fore as the defato means of securing web communication from fraudsters, snoopers, and other nefarious trades. Unfortunately, due to the nature of the technologies HTTPS and virtual hosts were not fully compatible.

Virtual hosts work based on host/server names. Examples of hostnames are example.com, eazybusiness.com, and blogger.com. The hostname provided by the client browser determined what one of its web sites the webserver servered to that client.

In order for a website to be able to offer the security of HTTPS, it must provide its own unique SSL certificate. This SSL cert is proof of the site's authenticity, and forms part of the protocol used to secure the communication between a user'…

Error sending Mail: 501 Syntax: HELO hostname

The exact error I found was:

javax.mail.MessagingException: 501 Syntax: HELO hostname


To fix it I had to set the hostname of the server


hostname $hostname.tld

Grails/Groovy deleting an element in a collection while iterating over it

I ran into a recent problem whereby I wanted to delete a sub-set of the elements in a list after processing all elements in the list. The general gist of the logic was:


apples.each { apple ->
if(apple.red) apple.delete()
}


which resulted in a java.util.ConcurrentModificationException exception.

The solution is to remove the element from the interator before deleting it.


Iterator itr = apples.iterator()
while(itr.hasNext()){
def apple = itr.next()
itr.remove()
apple.delete()
}


For more a little more detail see this thread