CADESUser DocumentationCADES Cloud User GuideAdditional Cloud ResourcesRun a Simple Web Server

Run a Simple Web Server

The following documentation will show you how to launch an Instance using the default Security Group. Once running, we will enable a basic HTTP service on port 80 by adding an additional Security Group.

Launch an Instance Using Horizon

  1. Navigate to the Horizon web interface at https://cloud.cades.ornl.gov/.
  2. Log in with your UCAMS credentials.
    • Domain: ornl
    • Username: Your three-letter UCAMS ID
    • Password: Your UCAMS password
  3. Navigate to ProjectComputeInstances.
  4. Click the Launch Instance button, and complete the launch instance wizard.
    • For this exercise use the Default security group.

If you have never launched a VM Instance before, check out the tutorial linked below before proceeding.

📖   How to: Launch a VM Instance from an Image

Add Rule for TCP Traffic

Once we have our VM Instance up and running, we need to make sure that the Instance can receive incoming traffic on port 80. We'll create a custom Security Group, add the required rule for HTTP traffic to our new (or existing) Security Group, and assign that Security Group to our VM Instance.

If you require HTTPS support on port 443, see our SSL - Let's Encrypt documentation.

Create Custom Security Group

  1. Navigate to ProjectComputeAccess & SecuritySecurity Groups.
  2. Click + Create Security Group at the top right of the Security Groups table.
  3. In the resulting dialog, fill out the Name and Description (optional) fields.
    • We're using http-server for this example.
  4. Click the Create Security Group button.

Your new Security Group should now be available in the Security Groups table.

Alternatively, you can modify an existing group using the corresponding Manage Rules button.

Add Rule to Custom Security Group

  1. Find the newly created http-server rule on the Security Groups tab.
  2. Click the Manage Rules button.
  3. On the Manage Rules screen, click the Add Rule button.
  4. In the resulting dialog, click the drop-down field under Rule.
  5. Choose the HTTP rule template from the drop-down list.
    • Choosing the HTTP template will automatically set the port to 80 and set the direction to Ingress.
  6. In the Remote box, choose CIDR (preferred) and leave the field as 0.0.0.0/0 or enter the desired inter-domain range. See CIDR examples for more information.
  7. Click Add at the bottom of the dialog box to implement your custom rule.
  8. Confirm your new custom rule is displayed in the Manage Rules screen.

Add New Security Group to Your VM Instance

  1. Navigate to ProjectComputeInstances, and find the Instance on which you would like to run your HTTP server.
  2. Click the ▾ drop-down menu on your Instance's listing, and select Edit Security Groups from the resulting menu.
  3. In the resulting window, click + to add the http-server security group to your VM Instance.
  4. Click Save to associate your http-server security group with your Instance.

Connect to Your Instance Using SSH

  1. Open a Bash terminal.
  2. Execute $ ssh cades@128.219.186.42.
    • Replace 128.219.186.42 with the IP address of your own Instance.
  3. You should now be connected to your VM Instance via SSH.

For more detailed information on connecting to your VM Instance using SSH, please see the SSH tutorials, linked below.

📖   How to: Access Your VM Instance Using SSH

For Windows users, we have developed a separate tutorial that walks you through connecting to your VM Instance using PuTTY's SSH client.

📖   How to: Access Your VM Instance Using PuTTY (Windows)

Set up Your Web Server

For the web server, we need to create a web directory and populate it with a basic index.html page.

  1. Execute the following in the VM's Bash terminal.

    $ mkdir www
    $ cd www
    

    This will create a www directory. Next, we need to open a new file (index.html) in the VIM text editor and populate it with some basic HTML markup.

  2. In the Bash terminal, execute $ vim index.html to create the new file and open it in VIM.

  3. Once in VIM, add the following lines to your file.

    <html>
     <head>
        <title>
            Hello world!
        </title>
     </head>
     <body>
        <h1>Hello world!</h1>
     </body>
    </html>
    
  4. Save your new file: press the Esc key, type :x, and then hit the Return key.

Now that we have our files in place, we can start a simple web server using Python.

  1. Ensure that you are still in the www directory where you placed your index.html file.
  2. Execute $ sudo python -m SimpleHTTPServer 80 in your VM's Bash terminal. A message will confirm that the server is running.

Test the Web Server

You should now be able to access your "hello world" page from a web browser by entering the IP address of your instance as the URL.

Troubleshooting

If you get an error when attempting to navigate to your Instance's IP using a browser, ensure that:

  • You used the external network option when you configured your Instance.
  • You are within the ORNL network or you have added a SAFER firewall exception for your VM Instance's IP address on Port 80 (or whatever port you specified in the Python command).
  • You have a Rule in your Security Group that grants access to your VM Instance on Port 80 (or whatever port you specified in the Python command).
  • Your Python server is active on your VM Instance.

Do You Need HTTPS?

results matching ""

    No results matching ""