Replace '_' in paths in werc's docs section with '-', and set up apropriate redirects to avoid broken links.

This commit is contained in:
Uriel 2010-05-30 18:04:04 +00:00
parent cbcfb4e6a3
commit 31bd20251d
15 changed files with 1 additions and 0 deletions

View file

@ -0,0 +1,16 @@
Setting Up Your HTTP Server to Run Werc
=======================================
Werc should work with any web server that supports the CGI interface, and a few
that don't. Here are collected instructions and sample configurations for some
of the most popular HTTP servers that people has used with werc.
In general setup consists of mapping all paths for a virtual host to the
werc.rc script, usually in practice this means that the `document root` (or
similar concept) for a virtual host is mapped to
`/path/to/werc/sites/domain.name.com/`, and if no static file matches the
request, control is handed to werc.rc, this allows the HTTP server to handle
static files and werc to handle everything else (note that such a setup will
expose your `_werc/config` files, which usually should not be a security
issue).

View file

@ -0,0 +1,92 @@
Setup werc with Apache
======================
Note: Apache 2.x configuration should be similar to 1.3.x, but Apache 2.x is not recommended due to unwindy complexity, please use a saner web server.
Apache 1.3.x: minimalist configuration
======================================
No virtual hosts and let werc handle static files.
RewriteEngine On
ServerName test.cat-v.org
AddHandler cgi-script .rc
<Directory /var/www/werc/bin>
Options ExecCGI
</Directory>
<IfModule mod_dir.c>
DirectoryIndex /werc.rc
</IfModule>
RewriteRule /werc.rc /var/www/werc/bin/werc.rc
DocumentRoot /var/www/werc/bin/
ErrorDocument 404 /werc.rc
Apache 1.3.x: standard configuration
====================================
This lets apache handle static files.
<VirtualHost *>
RewriteEngine On
ServerName test.cat-v.org
AddHandler cgi-script .rc
<Directory /var/wwww/werc/bin>
Options ExecCGI
</Directory>
<IfModule mod_dir.c>
DirectoryIndex /werc.rc
</IfModule>
RewriteRule (.*) /var/www/werc/sites/%{HTTP_HOST}/$1
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* /var/www/werc/bin/werc.rc
RewriteRule /werc.rc /var/www/werc/bin/werc.rc
DocumentRoot /var/www/werc/bin/
ErrorDocument 404 /werc.rc
</VirtualHost>
Apache 1.3.x: advanced configuration
====================================
<VirtualHost *>
RewriteEngine On
ServerName cat-v.org
ServerAlias www.cat-v.org harmful.cat-v.org 9p.cat-v.org gsoc.cat-v.org doc.cat-v.org uriel.cat-v.org www.binarydream.org ninetimes.cat-v.org *.cat-v.org
AddHandler cgi-script .rc
AddHandler cgi-script .cgi
<Directory /home/uriel/cat-v.org/bin>
Options ExecCGI
</Directory>
<IfModule mod_dir.c>
DirectoryIndex /werc.rc
</IfModule>
RewriteRule ^/hg/(.*) /home/uriel/cat-v.org/bin/hgwebdir.cgi/$1 [L]
RewriteRule /pub/style/style.css /home/uriel/cat-v.org/pub/style/style.css [L]
RewriteRule /pub/ /home/uriel/cat-v.org/pub/ [L]
RewriteRule /favicon.ico /home/uriel/cat-v.org/pub/default_favicon.ico [L]
RewriteRule (.*) /home/uriel/cat-v.org/sites/%{HTTP_HOST}/$1
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* /home/uriel/cat-v.org/bin/werc.rc
RewriteRule /werc.rc /home/uriel/cat-v.org/bin/werc.rc
DocumentRoot /home/uriel/cat-v.org/bin/
ErrorDocument 404 /werc.rc
</VirtualHost>

View file

@ -0,0 +1,31 @@
Configuring werc with Cherokee
==============================
Contributed by sqweek, thanks!
Cherokee Version 0.7.1
----------------------
vserver!default!rule!600!only_secure = 0
vserver!default!rule!600!handler = cgi
vserver!default!rule!600!handler!error_handler = 1
vserver!default!rule!600!handler!check_file = 1
vserver!default!rule!600!handler!script_alias =
/usr/local/werc/bin/werc.rc
vserver!default!rule!600!handler!pass_req_headers = 0
vserver!default!rule!600!match = directory
vserver!default!rule!600!match!directory = /code
vserver!default!rule!600!match!final = 1
Cherokee Version 0.5.3
----------------------
Directory /code {
Handler cgi {
Scriptalias /usr/local/werc/bin/werc.rc
}
}
Isn't progress wonderful?

View file

@ -0,0 +1,16 @@
Hiawatha Web Server Configuration
---------------------------------
Contributed by sqweek, thanks!
This are the relevant bits:
CGIhandler = /usr/local/plan9/bin/rc:rc
ExecuteCGI = yes
RewriteURL = werc
UrlRewrite {
RewriteID = werc
Match ^(/code|/index|/contact|/clique).* Rewrite /werc.rc
Match ^/$ Rewrite /werc.rc
}

View file

@ -0,0 +1,44 @@
Setup werc with lighttpd
========================
You will need to enable to the following modules: `mod_cgi`, `mod_alias` and `mod_rewrite` (for non-minimal configurations).
You can also find `mod_setenv` useful to change werc's environment ($PATH in perticular)
Minimal setup
-------------
This is the most minimal setup, for a single domain, and lets werc handle static files.
$HTTP["host"] =~ "^test\.cat-v\.org$" {
index-file.names = ( )
server.error-handler-404 = "/werc.rc"
alias.url += ( "/werc.rc" => "/var/www/cat-v.org/bin/werc.rc" ) # Here use the path to werc.rc in your system.
cgi.assign += ( ".rc" => "")
server.dir-listing = "disable"
}
Advanced setup
--------------
A more ellaborate setup, using virtual hosts to handle multiple domains, and
alias to let lighttpd handle static files. Also show how to add external cgi's
to the setup, in this case Mercurial's web interface.
$HTTP["host"] =~ "^((harmful|9p|gsoc|doc|uriel|src|repo|www|)(\.|)cat-v\.org|(www\.)?binarydream.org|)$" {
index-file.names = ( )
evhost.path-pattern = "/var/www/cat-v.org/sites/%3.%0/"
server.error-handler-404 = "/werc.rc"
alias.url += ( "/pub/" => "/var/www/cat-v.org/pub/" )
alias.url += ( "/favicon.ico" => "/var/www/cat-v.org/pub/default_favicon.ico" )
alias.url += ( "/doc/" => "/var/www/cat-v.org/sites/doc.cat-v.org/" )
alias.url += ( "/werc.rc" => "/var/www/cat-v.org/bin/werc.rc" )
alias.url += ( "/debug.rc" => "/var/www/cat-v.org/bin/debug.rc" )
cgi.assign += ( ".rc" => "")
server.dir-listing = "disable"
cgi.assign += ( ".cgi" => "")
url.rewrite-once = ( "/hg/(.*)" => "/hg/hgwebdir.cgi/$1" )
alias.url += ( "/hg/" => "/var/www/cat-v.org/bin/" )
}

View file

@ -0,0 +1,96 @@
Setup werc with NGINX
=====================
You probably will want to to use fcgiwrap, called from spawn-fcgi or similar.
Here is an extremely basic nginx configuration, with this configuration static files will be handled by werc and not nginx, this is clearly dumb, but works:
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
error_log logs/error.log info;
pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name test.cat-v.org; # Replace with your domain name.
#charset utf-8;
#access_log logs/host.access.log main;
location / {
# FastCGI params, usually stored in fastcgi_params
# and imported with a command like the following:
#include fastcgi_params;
# Typical contents of fastcgi_params (inlined here):
fastcgi_pass localhost:9000;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
#fastcgi_param SCRIPT_FILENAME /var/www/werc/bin/werc.rc;
fastcgi_param SCRIPT_NAME /var/www/werc/bin/werc.rc;
#fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param REMOTE_USER $remote_user;
#root /var/www/werc/sites/$server_addr; # XXX This doesn't work, not sure why :(
root /;
#index index.html index.htm;
}
}
}
Then you can use spawn-fcgi or similar to get wrapcgi going:
spawn-fcgi -a 127.0.0.1 -p 9000 -f /home/uriel/dvl/ext/fcgiwrap/fcgiwrap # Use the path to your fcgiwrap binary here
Other Setups
------------
More elaborate setups with direct handling of static files, caching, and multiple fcgi/cgi handlers should be easy, if you have any please post them to the werc9 mailing list.

View file

@ -0,0 +1,60 @@
Nhttpd/Nostromo Web Server Configuration for Werc
==================================================
Contributed by nsz, thanks!
The last two sections are relevant: aliases (to make non-content site material,
like css, available) and virtual hosts (the document root is set to `werc.rc`
so it will handle every request).
# MAIN [MANDATORY]
servername main.host.com
serveradmin admin[at]mail.com
serverroot /var/nostromo
servermimes conf/mimes
logpid logs/nhttpd.pid
logaccess logs/access_log
docroot /var/nostromo/htdocs
docindex index.html
# SETUID [RECOMMENDED]
user nhttpd
# BASIC AUTHENTICATION [OPTIONAL]
#...
# SSL [OPTIONAL]
#...
# CUSTOM RESPONSES [OPTIONAL]
#...
# HOMEDIRS [OPTIONAL]
#...
# ALIASES [OPTIONAL]
/pub /path/to/werc/pub
# The following line doesn't work because nhttpd doesn't support file aliases yet.
#/favicon.ico /path/to/werc/pub/default_favicon.ico
# VIRTUAL HOSTS [OPTIONAL]
vhost1.com /path/to/werc/bin/werc.rc
vhost2.com /path/to/werc/bin/werc.rc
#...
To use werc on `main.host.com` as well just set `docroot` to `/path/to/werc/bin/werc.rc`
and set `docindex` to empty string.
There was a bug in nhttpd <=1.9, it did not set `SERVER_NAME` properly (left it `main.host.com`).
To solve this problem just add a
SERVER_NAME=$HTTP_HOST
line somewhere at the top of `werc.rc`.

View file

@ -0,0 +1,53 @@
Setup werc with Plan 9's httpd
==============================
There are two main options, you can use Russ Cox's magic to cgi translator
(found in his contrib dir as cgi.c), or you can use the following script which
while simpler, it also lacks some features at the moment.
Thanks to soul9 for the original idea of wrapping werc in a shell script that
would setup a cgi-like environment!
#!/bin/rc
SERVER_NAME=$2
REQUEST_URI=`{echo $*(15)}
REQUEST_URI=$REQUEST_URI(2)
REQUEST_URI=/
REQUEST_METHOD=$*(16)
PLAN9=/
echo 'HTTP/1.0 200 Ok
Connection: close
Server: werc/9.9.9' # This is whatever you like
cd /usr/web/bin/
rfork
/bin/rc < ./werc.rc >[2]/usr/glenda/tmp/w/log # Use whatever location you like to log stderr, but make sure it is writable by none.
Call this script werc-wrap, and put it in /rc/bin/ip/httpd/
Then in your /sys/lib/httpd.rewrite add a line like:
/w @/magic/werc-wrap
And this will run werc for all stuff under /w. Note that apparently httpd is
incapable of internally remapping the root directory, so until a solution is
found for this, you will have to keep your site in a sub-directory of the web
server root.
In your /lib/namespace.httpd you probably will want to add something along the
following lines to bind the werc directory into the httpd's namespace:
bind -b /usr/glenda/src/werc/ /usr/web/
bind /usr/glenda/src/werc/bin/ /usr/web/magic/
**Notes**: This is experimental and work in progress, there are a couple of issues
with the werc code itself that might need fixing, in particular you will need
to replace the '%($"extraHeaders%)' in lib/headers.tpl with '% echo
$"extraHeaders' no clue why.