Web Access to account data
Introduction:
Periodically, people would like to share data that they have processed on the Katahdin HPC system. Each account has the ability to have data become visible via HTTP/HTTPS, ie., the Web.
Making data available to the Web
TLDR:
If you just want the bare commands:
mkdir ~/WWW
ln -s ~/my_data_dir ~/WWW/my_data_dir
chmod o+x ~
echo "Options +Indexes" > ~/WWW/my_data_dir/.htaccess
The URL to get to the directory is:
http://katahdin.acg.maine.edu/~my_account/my_data_dir
where "my_account" refers to your account name and "my_data_dir" refers to the directory of data that you want to make available.
The Longer Version:
In order to describe how to do this, we will use a sample account named "abol". The HOME directory for this account is:
/home/abol
The abol account has data in a directory called /home/abol/data that we want to share over the web.
The first thing that is needed is to create a directory called WWW in the home directory:
/home/abol/WWW
One way to do this is to open a terminal ssh to Katahdin and run the commands:
mkdir ~/WWW
The ~ character refers to the HOME directory of the account. Here is what things look like so far:
Last login: Fri Aug 12 19:41:33 EDT 2022 on pts/37
[abol@katahdin ~]$ ls -al
total 2
drwxr-x--- 1 abol abol 6 Aug 12 19:28 .
drwxr-xr-x 1 root root 208 Aug 12 19:27 ..
-rw------- 1 abol abol 113 May 16 16:32 .bash_history
-rw-r--r-- 1 abol abol 18 Oct 16 2014 .bash_logout
-rw-r--r-- 1 abol abol 176 Oct 16 2014 .bash_profile
-rw-r--r-- 1 abol abol 269 Mar 23 2016 .bashrc
drwxrwxr-x 1 abol abol 1 Aug 12 19:48 data
drwxr-xr-x 1 abol abol 4 Aug 1 2012 pi_MPI
drwxr-xr-x 1 abol abol 1 Jul 30 2012 .vnc
[abol@katahdin ~]$ mkdir WWW
[abol@katahdin ~]$ ls -al
total 2
drwxr-x--- 1 abol abol 7 Aug 12 19:44 .
drwxr-xr-x 1 root root 208 Aug 12 19:27 ..
-rw------- 1 abol abol 113 May 16 16:32 .bash_history
-rw-r--r-- 1 abol abol 18 Oct 16 2014 .bash_logout
-rw-r--r-- 1 abol abol 176 Oct 16 2014 .bash_profile
-rw-r--r-- 1 abol abol 269 Mar 23 2016 .bashrc
drwxrwxr-x 1 abol abol 1 Aug 12 19:48 data
drwxr-xr-x 1 abol abol 4 Aug 1 2012 pi_MPI
drwxr-xr-x 1 abol abol 1 Jul 30 2012 .vnc
drwxrwxr-x 1 abol abol 0 Aug 12 19:49 WWW
As can be seen here, the WWW directory has been created. This is the Web Root directory for this account. Before it can be used though, a couple of things need to be done:
Security: By default, only the owner and the group that a new account belongs to can see the files and directories of the account. This is what drwxr-x--- (above) is showing. The last three permissions are blank, indicating that "Others" cannot access this directory. The web server running on Katahdin runs as user "apache" and is not a member of the "abol" group so the web server will not be able to get to this WWW directory. To change this, the following command needs to be run:
chmod o+x ~
Currently there is nothing in the WWW directory. Files can be copied into the directory but generally people want to keep their data where it is. The answer is to create a symbolic link to either a directory or file that points inside the WWW directory. In this case, we want to make the "data" directory visible to the Web, so we'll create a symbolic link with the command:
ln -s ~/data ~/WWW/data
This says to create a link called /home/abol/WWW/data that points to /home/abol/data (remember that ~ refers to /home/abol for this user).
Now everything seems ready, and it kind of is but to make it easier for people to see the data files via the web there is another step. The web server doesn't allow people to view listings of files and directories by default. If people are given the full URL of a data file, they can get to it but they can't browse the directory. For instance, there is a single file in the ~/data directory called "data.txt". To get to this file, you can type in the following in a web browser:
http://katahdin.acg.maine.edu/~abol/data/data.txt
And you should see in your web browser:
This is a sample DATA file.
However, if you try to just go to: http://katahdin.acg.maine.edu/~abol/data you will get an error like:
Forbidden
You don't have permission to access /~abol/data/ on this server.
This is because of the web server default permissions. To override these permissions a file called .htaccess needs to be put in the directory with a directive to override the defaults. You can do this with the command:
echo "Options +Indexes" > ~/WWW/data/.htaccess
This should now make it so the URL: http://katahdin.acg.maine.edu/~abol/data will show you:
This should be enough to get you going with sharing your data via the Web. If you have any problems, please let us know.