Category Archives: IT issues

Issues that come up in dealing with Linux, particularly related to the Raspberry Pi and related computers.

How do you run multiple web-servers on a single ip-address?

How does one run multiple websites of a single IP Address?

One way to do this is to use a server running Squid. The idea is that you point the router to go to the computer running squid when a request comes in for port 80. You then have to configure Squid to act as a ‘reverse proxy server’.  When I first did this I used Squid 2.7, so what I am about to write relates to that version of Squid. So follow the Wiki, or one of the tutorials on the internet, for installing Squid. The bit I found not well explained was the actual settings required in the Squid config file. So here is a way to look at what is needed.

The first bit is to set the server to service port 80 requests coming in from the router.  Use your favorite unix system editor to edit the file /etc/squid/config file. Locate the line containing the field ‘http_port, and change it to

http_port 80 accel vhost

Lets say your website server behind the router firewall  is called ‘websiteserver1’ and its on an LAN address of  Then you need the following two lines in the Squid Config file:

cache_peer parent 80 0 no-query originserver name=websiteerver1

Now you need to create a record that specifies all the websites that you want webserver1 to accept. Lets say the record for websiteserver1 will be called sites_webserver1. and the urls relating to that record are, , and Then the following line is required:

acl sites_websiteserver1 dstdomain

Now we need to specify the configuration for the cache that Squid will require. This is done using the line:

cache_peer_access websiteserver1 allow sites sites_websiteserver1

Finally you need to let Squid now which websites it is supposed to handle. This requires the line:

http_access allow sites_websiteserver1

Make sure that the last line in the http_access is:

http_access deny all

This last line ensures that all websites not in the list preceding the ‘deny_all’ will be the only sites that Squid will accept.

If you have done this for a number of website servers, say three of them, you should have a set of lines that looks something like the following:

cache_peer parent 80 0 no-query originserver name=websiteserver1

cache_peer parent 80 no-query originserver name=websiteserver2

cache_peer parent 80 no-query originserver name=websiteserver3

acl sites_websiteserver1 dstdomain

acl sites_websiteserver2 dstdomain

acl sites_websiteserver3 dstdomain

cache_peer_access websiteserver1 allow sites_websiteserver1

cache_peer_access websiteserver2 allow sites_websiteserver2

cache_peer_access websiteserver3 allow sites_websiteserver3

http_access allow sites_websiteserver1

http_access allow sites_websiteserver2

http_access allow sites_websiteserver3

http_access deny all



Changing the name of a linux system

So you want to change the name of a computer that is running Linux. Simple?
NOT… nothing is straight forward in Linux. Sure lots of programmers and IT developers will swear by Linux, but that doesn’t mean its straight-forward and neither is the documentation so spectacular either. Because so much of it is open-source you find all sorts of contradictory advice around the internet, and often it’s wrong anyway. So here is my attempt at contributing some consistency as I develop a few tutorials around some often encountered tasks.

This one is where you want to change the name of your Linux system so that when you look at your Local Area Network you will see the name of the computer rather than an IP address.
First you need to go to the file /etc/hosts. There you need to add (or change) the line

hosts yoursystemname

Then you need to edit the file /etc/hostname and change the name to