Posts Tagged ‘virtual hosts’

Lisp Web Server From Scratch using Hunchentoot and Nginx

November 9, 2010

**************************I tried my setup on Ubuntu 13.10 server and had some issues so I decided to update this article, unfortunately I dont have the time to rewrite it so I am just hacking the bits that where issues on Ubuntu 13.10**********************

So you want your own lisp web server to hack away at but where do you start? Well don’t despair, what follows is a recipe for getting such a server running in no time. (Don’t worry you won’t be coding it from scratch you will be building it with a “software lego” set.)

Much of what you will see here was taken from different websites especially these two great articles and These articles do a better job of explaining what is afoot than my posting here. Please do go to these articles and show your appreciation for the hard work that went into them by leaving a comment.

All that I am doing is giving you an A to Z recipe in one place to get you going.

There are a lot of good articles in the slicehost articles collection as well that are worth a read on their own if you want to understand more about the iptables and stuff.



Hunchentoot Virtual Hosts with nginx

August 5, 2009

(This posting is dated have a look at for a newer approach)

I looked at a couple of options to do virtual hosts with hunchentoot, but eventually I settled on nginx. It might not be the best solution but it does what i need with minimal effort. (I did not have to read and understand the source code to be able to use it or compile it or patch it or any of those nasty things that causes you to pull your hair out trying to remember or repeat it some other time.)

My setup is as follows. I have a vps server that is starting up sbcl in a screen session that loads one instance of hunchentoot. For me to be able to run multiple sites (same file names (NOT SAME FILES)) from the one instance of hunchentoot I used a prefix of the site name to differentiate individual sites. No its not greek.


(No I am not running huncnetoot on port 80 because that would cause me to pull out more hair.)

These then have to translate to domains like (http://localhost:8090/my-site/) and (http://localhost:8090/my-other-site/).

I am not going to go into how to setup hunctentoot, there are plenty of tutorials on that subject, thou I would advise going the clbuild route.

Here is how I installed nginx on Ubuntu 9.04.

1. sudo apt-get nginx
(Yes I know it might not be the latest version but it will only serve as a reverse proxy and that part works fine.)

2. sudo gedit /etc/nginx/sites-available/default

I deleted all the stuff that was in there and replaced it with the following

server {
        #The port nginx must listen on
        listen   80;

        #The name of the domain to route

        #To default to the home page from;
        rewrite ^(.*)/$ $1/home.html;

        location / {
            #Where to route the listed domains our case hunchnetoot
            proxy_pass http://localhost:8090/my-site/;

            #Some more config stuff if you want it. This can be moved to /etc/nginx/proxy.conf and 
            #the following line can replace everything up to proxy_buffers:
            # include /etc/nginx/proxy.conf;
            proxy_redirect          off;
            proxy_set_header        Host            $host;
            proxy_set_header        X-Real-IP       $remote_addr;
            proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
            client_max_body_size    10m;
            client_body_buffer_size 128k;
            proxy_connect_timeout   90;
            proxy_send_timeout      90;
            proxy_read_timeout      90;
            proxy_buffers           32 4k;
        #This is needed to handle the links to all the images,stylesheets and javascript files 
        #This was also the bit that was missing from all the other examples I found. 
        location /mu-site/ {
                proxy_pass http://localhost:8090/my-site/;

server {     
        listen   80;

        rewrite ^(.*)/$ $1/home.html;
        location / {
            proxy_pass http://localhost:8090/my-other-site/;
        location /my-other-site/ {
                proxy_pass http://localhost:8090/my-other-site/;

Save and start nginx with sudo /etc/init.d/nginx start.

Now go to your favourate browser and browse for or what ever you used as you domain.

PS: If anybody can give me an example of how to use hunchentoot-vhost to do the same I would really appreciate it.