Setting Up A Cloud Server - Part One!

This is the first entry to our very own development blog.

Over the next few months we will be focusing mainly upon iOS development as we begin giving life to a few game ideas we have.

But first, let's take a look at how this website was created!

In part one - we will talk about setting up a cloud server.

Server

We created a new server instance using Rackspace's brilliant cloud hosting facility - opting for a 256mb RAM, 10GB HDD Ubuntu 10.04 Lucid Lynx starter image. At a cost of $0.015 per hour - and a GBP exchange rate of about $1.66 to £1 - it is fairly cheap, oh and some small bandwidth costs too - check out their offering.

With such as small amount of ram, and the primary use of this 'cloud slice' being the hosting of this blog, we didn't want to install the full blown wordpress or [insert other blog cms] software, but rather create our own lightweight blog front and backend - something that has just the right amount of features. Not only that, but we can also take pride that as an application development company, we created our own software for our website!

When you sign up to rackspace and create your first server instance you are given and later emailed the IP for the server and root passwords.

If you want to you a domain name to access the server, you have the ability to edit DNS settings from within your control panel. At time of writing, all you need to do with your domain provider is change the nameservers for the domain to the following:


dns1.stabletransit.com

dns2.stabletransit.com

Then in rackspace go to cloud servers overview screen and from the dns tab for each domain

  • add an A record - name: domain.com content: ip address ttl: 300 type: A
  • (if mailserver) add an MX record - name: domain.com content: domain.com priority: first record 10, next 20 etc ttl: 300 type: MX
  • add a CNAME record - name: www.domain.com content: domain.com ttl: 300 type: CNAME
  • for any intended subdomains add a CNAME record for them too (cname as they are on same ip, otherwise A record)
  • set the reverse dns as the hostname of the server ---> eg. mainserver.domain.com. (dot at end too)
Server Software

The linux based server had the normal configuration done as per usual barebones installations:

  • Changing root password and create a new user

    SSH into the cloud server instance, logging in as root - we are using an Apple computer so can use the terminal application - on windows you can use a program such as putty.

    # ssh [email protected]

    As you are now logged in as root, using the below command you can change the password from the one Rackspace gave you when creating the server instance.

    # passwd

    Still logged in as root, you create a new user (the user you will work as). You will be prompted by the operating system for a new password for this user as well as other information such as name and contact details.

    You should avoid logging in as root, in order to prevent opportunities where the cloud server could be compromised.

    # adduser mynewusername

    Using the newly created user 'mynewusername' for all tasks will require you to have sudo (Super User) privileges - this means that this user could, with a password, have full root access.

    # usermod -a -G sudo mynewusername

    # visudo

    The previous command will bring up the configuration file for the sudo program. Toward the bottom of the file you will see the following:

      # Uncomment to allow members of group sudo to not need a password 
       # (Note that later entries override this, so you might need to move 
       # it further down) 
       # %sudo ALL=NOPASSWD: ALL 
       

    Add the following under it:

       ## Allows people in group to run all commands 
       %sudo  ALL=(ALL)       ALL
       

    Save the file by pressing CTRL-X, Y and then ENTER - this allows the sudo group to have full sudo (Super User) privileges, a group of which 'mynewusername' is now a member of.

    From now on you can login as follows:

       # ssh [email protected]
       

    Once logged in, by type sudo su and pressing Enter will prompt you for your password - after which you have root/super user privileges.

  • Basic Server Security

    Linux distributions such as Ubuntu can use package managers to install/upgrade sofware - packages such as 'apt-get' and 'aptitude'.

    Firstly update the sources repository for these by editing the follwing file:

    # sudo nano /etc/apt/sources.list

    Add the following lines to it:

    deb http://ppa.launchpad.net/brianmercer/php/ubuntu lucid main

    deb-src http://ppa.launchpad.net/brianmercer/php/ubuntu lucid main

    Now run the following command to add the signed key for these sources:

    # sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 8D0DC64F

    You can now update the package manager caches:

    # apt-get update
    # apt-get upgrade
    # aptitude update
    # aptitude upgrade
    

    When upgrading you will be prompted to confirm, enter Y and press ENTER.

    Firewalls

    The Linux firewall system is controlled by the configuration of iptables application. This can be viewed by running the following command:

    # iptables -L

    This would provide the following output:

    Chain INPUT (policy ACCEPT)
    target     prot opt source               destination         
    ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED 
    ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:ssh 
    
    Chain FORWARD (policy ACCEPT)
    target     prot opt source               destination         
    
    Chain OUTPUT (policy ACCEPT)
    target     prot opt source               destination
        

    You now need to add additional rules to the iptables in order to control the flow in and out of the cloud server instance. Start by adding the following rules line by line:

    Allowing established connections:

    # iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

    Allowing SSH traffic:

    # iptables -A INPUT -p tcp --dport ssh -j ACCEPT

    Allowing HTTP traffic:

    # iptables -A INPUT -p tcp --dport 80 -j ACCEPT

    Allowing FTP traffic:

    # iptables -A INPUT -p tcp --dport 20 -j ACCEPT

    Allowing FTP traffic:

    # iptables -A INPUT -p tcp --dport 21 -j ACCEPT

    Allowing SMTP traffic:

    # iptables -A INPUT -p tcp --dport 25 -j ACCEPT

    Drop remaining traffic:

    # iptables -A INPUT -j DROP

    Allowing loopback traffic:

    # iptables -I INPUT 1 -i lo -j ACCEPT

    Now with all these rules input, you can view the tables again by typing:

    # iptbles -L -v

    Save the rules by following these commands:

    # iptables-save > /etc/iptables.rules
    

    Make sure the iptables.rules is run at every boot up:

    # nano /etc/network/if-pre-up.d/iptaload
    

    The text editor will load, paste in the following:

    #!/bin/sh
    iptables-restore < /etc/iptables.rules
    exit 0
    

    Save the file by pressing CTRL-X, then Y and Enter.

    You will also need to create a script to run if the server is shutdown:

    # nano /etc/network/if-post-down.d/iptasave

    In the text editor, paste the following:

    #!/bin/sh
    if [ -f /etc/iptables.downrules ]; then
       iptables-restore < /etc/iptables.downrules
    fi
    iptables-save -c > /etc/iptables.save
    exit 0
    

    Save the file.

    Set permissions on these two scripts to make them executable:

    # chmod +x /etc/network/if-post-down.d/iptasave
    # chmod +x /etc/network/if-pre-up.d/iptaload
    

Now the basic server is set up, you have created users, allowed super user privileges using the sudo command, updated application repositories and set up firewalls.

In the next article, we will do a run through on installing and setting up FTP, setting time zones and installing postfix to enable outgoing email from this server.

Category: cloud server

Tags: apt get aptitude cloud server dns iptables rackspace ubuntu

1 comment

Login or Register to post comments.

12/03/2012 23:16:12

Steve.H

Awesome write up, even if its a little old most of the code is still good. Thanks Geeky! :P

Steve.H

My Work!

MelodyBox watchOS app logo

MelodyBox watchOS app

Make music on your Apple Watch!

view app
Lyrically watchOS app logo

Lyrically watchOS app

Guess the song by listening to song lyrics on your wrist!

view app
SoundBirdy watchOS app logo

SoundBirdy watchOS app

Full-featured Soundboard for the Apple Watch Speaker

view app
Value My Car Android app logo

Value My Car Android app

Value any car for free - all makes and models available.

Get a free valuation of any car based on car depreciation trends for the specific make and model, the price you paid, your length of ownership and mileage covered. You can find out how much a car purchased at any point during its life-cycle will continue to depreciate.

view app
Value My Car iOS app logo

Value My Car iOS app

Value any car for free - all makes and models available.

Get a free valuation of any car based on car depreciation trends for the specific make and model, the price you paid, your length of ownership and mileage covered. You can find out how much a car purchased at any point during its life-cycle will continue to depreciate.

view app
NiceAreas.co.uk Website logo

NiceAreas.co.uk Website

Search For UK Areas Based on any Criteria

A number of tools to help research parts of the UK down to postcode sector level using multiple datasets and a variety of data combination and aggregation.

Including crime, house prices, travel links, jobs and more!

visit website
Mortgage Calculator Expert iOS app logo

Mortgage Calculator Expert iOS app

This comprehensive mortgage calculator includes eight different calculators in one app!

Adjust repayment types, rate types, initial offers/periods, base rates, terms, SVR's, overpayments, collars/caps, any fees (add to loan or upfront), mortgage start dates, simulated rate changes and more!

view app
Mortgage Calculator Expert Android app logo

Mortgage Calculator Expert Android app

This comprehensive mortgage calculator includes eight different calculators in one app!

Adjust repayment types, rate types, initial offers/periods, base rates, terms, SVR's, overpayments, collars/caps, any fees (add to loan or upfront), mortgage start dates, simulated rate changes and more!

view app
Amazon Alexa Skills logo

Amazon Alexa Skills

Multiple Alexa Skills

Voice-first (with additional display elements too) skills for Alexa devices.

Including:

BrainPickers! Guess The ... series of games.

SalaryBee - Salary calculations by voice.

TheMoneyCalculator - Finance calculations by voice.

NiceAreas - Property valuations, Area information and census information by voice.

Who Said That? Friends Quiz.

..plus...more to come!

visit website
UKTaxCalculators.co.uk Amazon app logo

UKTaxCalculators.co.uk Amazon app

The UK's most comprehensive FREE tax calculator app

The website condensed into a full featured and easy to use Amazon app!

Check tax on any income source, compare salaries and much more!

view app
UK Tax Pro iOS app logo

UK Tax Pro iOS app

Calculate UK Tax on any income type with single or multiple income sources.

Get a full breakdown of your tax, print/email from within the app.

Full compliment of professional features such as rates and allowances, news, guides and calendars.

view app
UKTaxCalculators.co.uk Android app logo

UKTaxCalculators.co.uk Android app

The UK's most comprehensive FREE tax calculator app

The website condensed into a full featured and easy to use Android app!

Check tax on any income source, compare salaries and much more!

view app
UKTaxCalculators.co.uk iOS app logo

UKTaxCalculators.co.uk iOS app

The UK's most comprehensive FREE tax calculator app

The website condensed into a full featured and easy to use iPhone/iPad/iPod app!

Check tax on any income source, compare salaries and much more!

view app
Parcel Dogs Game For iOS logo

Parcel Dogs Game For iOS

This 'top-down' racing game involves the player taking the role of Jim, our Speedy Parcel delivery dog. Now Jim has to go around his picking up parcels with the help of his map but has a hard time of it thanks to his nemesis Crazy Dave.
visit website
UKTaxCalculators.co.uk Website logo

UKTaxCalculators.co.uk Website

The UK's most comprehensive FREE online tax calculator suite

The Tax Calculator provides a full breakdown of tax for PAYE, CIS or Self Employed individuals providing options for Pension Calculations, Tax Codes, NIC Letters, Bonuses, Salary Sacrifice Schemes and more.

For people with multiple income sources, the UK Tax Calculators Wizard calculates every UK tax across all incomes in the same manner a tax return would.

visit website
Walleto.co.uk Website logo

Walleto.co.uk Website

The first truly easy to use, free online budget planner

There has never been an easier way to forecast your finances in less 5 minutes!

The budget calculator takes all your income details, across any type of income, calculates the taxes due, subtracts your expenses (both from extensive presets to your own defined expenses). You are presented with an online forecast, comparisons with other users with similar households as well as a printable report version to use as income and expenses chart.

visit website
TheMoneyCalculator.com Website logo

TheMoneyCalculator.com Website

Full featured online mortgage and loan calculators

You can use this website to calculate mortgage payments, forecast future interest rate effects, calculate remaining balances, check debt consolidation options, plan your savings, plan your pension as well as plan for your future house purchase. A lot of planning made easy!

Find a professional mortgage adviser or financial adviser online through our UK-wide network.

visit website
WhereDidMyTaxGo.co.uk Website logo

WhereDidMyTaxGo.co.uk Website

Ever wanted to know where the UK Government has been spending YOUR tax payments?

The WhereDidMyTaxGo.co.uk website takes your gross income since 2003, calculates your taxes (PAYE only), and uses the Governments expenditure data to give you an approximation of how much of your actual payments were spent where.

The personalised aspect of this website is a unique use of Government data.

visit website
TaxPenny.co.uk Website logo

TaxPenny.co.uk Website

Finding an Accountant the Smart Way

TaxPenny provide an online platform for accountants and those seeking an accountant to connect. Potential clients describe their circumstances, the work required and set a maximum price rage. Quotes are returned to clients within 1 working day. Accountants are able to search for new clients through various criteria and bid auction style for leads or purchase adhoc.

visit website
World Tax Calc Android app logo

World Tax Calc Android app

Compare Tax and Cost of Living of Major Economies

Calculate and/or compare taxes for major economies across the world, see differences in take home pay and see a cost of living comparison with a list of common purchases people make.

view app
World Tax Calculator iOS app logo

World Tax Calculator iOS app

Compare Tax and Cost of Living of Major Economies

Calculate and/or compare taxes for major economies across the world, see differences in take home pay and see a cost of living comparison with a list of common purchases people make.

view app

My Blog!

27/01/15 19:37:10

Using Cloud-based Load Balancing To Horizontally Scale Effectively

In this quick guide, we will go through what is required to convert an existing singular LAMP setup to a horizontally distributed network of servers sitting behind a Load Balancer. This guide will utilise a number of services from Rackspace Cloud.

cloud server

0

19/12/14 11:13:49

Creating Servers For Load Balancing

In this step-by-step guide we create the underlying server structure required for successful load balancing.

cloud server

0

14/09/14 14:40:59

Creating a Shared Memcached Cloud Instance

Key-value memory based storage can be a significant performance boost, as well as load reducer, for database heavy websites. Follow our step-by-step guide to setting one up using the Memcached application.

cloud server

0

27/06/14 12:12:01

Copying Data Across From Existing MySQL Databases to a Cloud Database

Now that you have created a database in the cloud, how do you get it populated as quickly as possible. Follow our step-by-step guide.

cloud server

0

27/03/14 13:14:05

Converting a Single Node MySQL Application to a Cloud Databases Instance

Switching from an existing single database application to a database in the cloud requires two steps. First is to actually create the cloud database instance. The second is to migrate your existing data across. We describe the steps required.

cloud server

0

.. or read all of my blog!

Get in touch!

Do you have any questions for me? An idea for an exciting new website or mobile application? Maybe you just want to leave a comment regarding one of my websites or apps? If yes then you've found the right place!

Complete the form below and I will get back to you as soon as possible. If you would prefer to get in touch via Twitter, you can reach me there using @rayarmanappdev.