E_WEB Server Ver. 1.2c by The Wizards and hard workers of E_MOO Documentation by GE@PythonMOO [In progress] Intro ----- E_WEB is a web server for your moo that lets objects return html codes to a port on the server from inside the MOO. Features -------- Basic Install : Main web page, all players/objects can return html text to make their objects readable to the world. Extra Install (Basic + Generic Web Request Handler) : VRML, who list, view object code, view objects, read mailing lists, insert CGI. Installation ------------ 1. Basic Install: Insert this text into your MOO 2. Extras: Insert this text into your MOO 3. @set $httpd.server_name to "your moo server" 4. @set $httpd.server_port to NOTE: Do not use the default port 80 if you are on a system with a real web server. 5. Edit #0:server_started and insert this line: $httpd:start_listening() This will start the http object with the MOO. 6. Type: ;$httpd:start_listening() Starts the http object now. 7. Edit $httpd.home_page_body to return your default home page html. 8. Make :http_request(tnt)(+x) verbs on objects to allow them to return html code. Port 80 Frolics --------------- You may wish to enable people to use the http service through the default port 80. If a conventional web server is already running, this can be difficult. This can be worked around quite effectively with the Apache webserver, and possibly others. This solution proxies certain requests through to the moo, an advantage to this is that you can also serve non-moo content (eg images and static documents) without adding extra load. You should probably talk to your sysop about doing this, since it requires server-wide changes. In httpd.conf, add: LoadModule proxy_module /libproxy.so LoadModule rewrite_module /mod_rewrite.so ProxyRequests Off The following line should be added to the MOO virtual host definition in httpd.conf ProxyPassReverse / http://127.0.0.1:E_WEBport This will enable the proxy module, but disallow the conventional proxy support. Both are recommended for security reasons. The last line would be defined in .htaccess, but is not allowed there, it will rewrite any REDIRECT headers sent by the E_WEB to the proper counterpart. That is all that needs changing in the main server config, you should restart apache so it re-reads the config file. Create a .htaccess file in your designated document root: RewriteEngine On RewriteCond $1 !apache(.*) RewriteCond $1 !manual(.*) RewriteRule (.*) http://127.0.0.1:E_WEBport/$1 [P] The above will catch all requests BUT the ones to /apache /manual or /mirror, or any items below them. The final line will redirect any that are not one of the above and pass the request through to the E_WEB. In the case of this moo, the apache stores images and other non-moo files, manual contains the Lambda programmers manual. Verbs ----- $httpd Core :start_listening() => port or error Starts the MOO server listening on $httpd.server_port. Run by default from $server_started() :do_login_command() => 0 Called by MOO server when first line of data is sent down a connection. Arguments to this are ignored, instead, input is immediately held, and then read. It will try to log, debug, and handle_request (those verbs in that order) and if failing, will return a html traceback via the connection. :log_connection() Unprogrammed :debug(msg, description) => msg When .debug==1, will tell the room it's in: description (or caller): msg :handle_request(list lines) => 0 This block of code handles the request, parsing the url and passing it to the appropriate handler. Text recieved back from the handler is checked for headers, and if there are none, then applies the default ok set. Text then passed to :notify_connection. :complete_url(path) => url Returns full URL of given path, using $httpd.server_name and .server_port Eg: "/test" => "http://domain.name:port/test" :parse_url(path) => list Returns a URL path in the form of a list Example: $httpd:parse_url("/users/Fabuley?Planet=Neptune") => {"/users", "/Fabuley", "?Planet=Neptune"} :GET(list url) (aka :HEAD) => list page_content GET and HEAD method handler, matches object, if not valid it returns error page, if valid will call the request verb (usually http_request) on that object. Returns whatever the request verb returns. If a HEAD request, and the request verb does not return headers, will return default ok. :POST :match_object(path) => object This verb takes the first element of a list of the form from :parse_url. If empty, it will return $web_objects.default ($httpd); if it's a number, and an object with that number exists and has a http_request (or whatever your $httpd.request_method_name is) verb, then it will be returned; if is a property on $web_objects, then that value returned; finally other objects such as players and mailing lists are checked.