#!/bin/rc if(~ $1 v){ peep $0 exit } cat<<-eof- basic

Basic Properties


Pegasus is running on Plan9 and Plan9 support per process name space. Pegasus provides a per user name space for httpd service using this Plan9 power. I will show you in this page what is `per user name space'.

I mean by the word `user':

  1. A user of the system. Any user can have his/her web page in the direcory:
    $$home/web
  2. A virtual host of the server. Fore example pegasus.aichi-u.ac.jp is one of virtual hosts of this server. It is defined in /sys/lib/httpd.rewrite:
    	http://pegasus	*/usr/pegasus/www

First of all, I would like to notice you that this is a CGI program of Pegasus. You can look the code. click

name space of http service

The following is an output of

ls -l /

-eof-
ls -l /
cat<<-eof-
This name space is configured in the file:
/lib/namespace.httpd.

User can merge his/her files (in `afer' mode of bind) to the directories provided by the server administrator.

Directories /doc and /etc are very special. They are provide by the user.
Each user has these two directories and they are hided from other users.
(Even if these direcories have already provided by system administrator, they are replaced by users one.)

Directory /doc is the document root of each user, and some files in /etc controls access or redirects the request to his/her web page.

Document root

You can observe:
/doc
in the output. This is a document root of our users.

Let's look directories under the document root.

ls -l /doc

The output is:

-eof-
ls -l /doc
cat<<-eof-
Note that they are directories of this home page.

There are some other home pages in our server. All of their document root have a same name /doc. However you can't see them in this name space. They are hidden! It is a power of Plan9/Pegasus.

Access control and redirection by user

Pegasus permit for each user to have his/her own direcory outside of document space. The name is /etc. In this directory user can have some files such as passwd , allow and rewrite to control accesses or redirect requests to his/her web pages.
-eof-
ls -l /etc
cat<<-eof-

Directories in root directory

Directories that is seen in the root directory is mainly provide by the server administrator. You can see how it is organized in /lib/namespace.httpd.
Users can add some directories to them. You can see the example in the above output.

The directories:

-eof-
ls -l / |grep sys
cat<<-eof-
came from:
/usr/web/*

On the other hands the directories:

-eof-
ls -l /|grep -v sys
cat<<-eof-
came from:
/usr/pegasus/www/*

These directories are mixed in the name space of http service.

Note that virtual host pegasus is one of users of this server. You will see similar result for other users.

How users can have their home page.

Home page in Pegasus can be classified in three categories:
1. official home page
2. home page of virtual host
3. personal home page

Name space of official home page is organized in /lib/namespace.httpd. The real document root can be located anywhere.

Home page of virtual host is assigned in /sys/lib/httpd.rewrite.
This file defines the rule to translate URI to URI so that the server can redirect the request from the clients.

You can find the line in the file:
http://pegasus */usr/pegasus

The line with * in the beginning of second field is special. Such a line defines the location of directory for virtual host in real name space.

User's home directory in URI is conventionally expressed like:
/~alice
where alice stands for any user of httpd server.
A user who has a directory named web/doc under his/her home directory can have his/her home page. The directory automatically becomes a home page without any configuration in system file such as /lib/namespace.httpd nor /sys/lib/httpd.rewrite.
Thus, user alice who has:
/usr/alice/web/doc/index.html
have her home page, and the page will be seen as
/doc/index.html
in the name space of http service


see this script -eof-