Header left.png

Web Services

From Systems Group
Jump to: navigation, search

Preamble

The ODU CS Department provides faculty and students the ability to host web pages from their CS Unix Account.

Users interact with this system through two main components, the ~/secure_html directory and the command line tool webcli

Important Knowledge

Your home directory that contains ~/secure_html can be access on our Linux Servers.

Usage of these Web Services requires an understanding of Linux Permissions, if you are not familiar with these please see this Introduction to Linux Permissions written by Mitchell Anicas.

The ~/secure_html directory and all of its content must have a specific set of linux permissions for it to be properly accessible to the Webserver that is serving it.

  • Directories must have other read and execute
  • Files must have other read and if this file is supposed to be executed such as php it must also have other execute

How it works

User websites are hosted at https://www.cs.odu.edu/~username/ where the document root is /home/username/secure_html/.

Example

Path URL
/home/username/secure_html/index.html https://www.cs.odu.edu/~username/index.html

Each user gets a unique webserver that is automatically created and does not serve content until created.

There are two ways for this webserver to be created.

The simplest method for having your webserver created is using the "autospin" feature, by navigating to a URL under where your content *should* be the system will automatically "spin" (create and turn on) the personalized webserver. Anyone that navigates to the URL will cause the webserver to be created. If for some reason the webserver of a specific user were to no longer be available, potentially due to an outage, the next navigation to a webpage will also cause it to be autospun.

The other method is to use the Webcli tool available on the Linux Servers to start the webserver manually, for more information see WebCLI below

Common Questions or Issues

Redirecting to external site

Problem

Some users would like cs.odu.edu/~username to redirect to an external page.

Solution

Create a file called .htaccess in the path you want to redirect. Ensure the .htaccess file has 755 permissions.

In the file, put the contents:

Redirect 301 / http://www.newdomain.com/

Example:

~/secure_html/.htaccess >

Redirect 301 / https://www.google.com/

Indexing (Error 403)

Problem

Going to cs.odu.edu/~username gives a 403 error but all folders and directories have the correct permissions

Reason

Indexing is off by default

Solution

One solution is to create an index.html.

Another solution is to make a .htaccess file and add the line "Options +indexes" to the directory you want to do indexing.

WebCLI

Basic Usage

  1. SSH into the department's Linux servers
  1. Run the following commands to create a directory at /home/<username>/secure_html and give read and directory listing permissions to other user set:
 mkdir ~/secure_html
 chmod o+rx ~/secure_html
  1. Add some serve-able content to your ~/secure_html directory, a simple example:
 echo "Hello world!" > ~/secure_html/index.html
 chmod o+r ~/secure_html/index.html
  1. To start the personal webserver, users must use the webcli tool as follows:
 webcli start
This command will prompt for your CS account password, to ensure only you can start your own webpage.
A successful command will look like so:
 $ webcli start
 Username: <username>
 Password: **********
 Service is starting. It will be available at https://www.cs.odu.edu/~<username> soon.
 This may take a few moments.

This command starts a personal webserver for the individual user, by default it runs with Apache PHP7. See the advanced usage for more information.

Advanced Usage

The webcli tool is used for controlling the user's personal webserver through use of Kubernetes containerization. With this tool, the user can pick between multiple provided webserver templates to build their webpage using their desired technology.

The webcli tool has multiple subcommands and parameters for the available actions with this solution:

  • List Images - List the available container images for your personal webserver.
 webcli listimages
  • Start - turn on your personal webserver container.
 webcli start
This subcommand can be given the following optional subflags:
--image IMAGE, -i IMAGE - select the image to use for your webserver. find the available images using `listimages`.
  • Stop - turn off your personal webserver container.
 webcli stop
  • Restart - restart your personal webserver container.
 webcli restart
  • Status - determine whether your personal webserver container is currently running.
 webcli status
  • Logs - retrieve the access logs for your webserver..
 webcli logs --tail=<number of lines>


Currently Available Webserver Images
Image name Description Notes
apache-php7 Runs an Apache PHP 7 webserver. Supports .htaccess files
nginx Runs a basic static webpage served by Nginx. Does not support .htaccess files or PHP.
apache-php7-oracle-plguins Image based on apache-php7 with PHP plugins for interacting with Oracle Databases, used for CS450/550.