------------------------------------------------------------------------------- access control Directory will refer to directories or symbolic links the server is passing though to reach the relevent document. for example /www is a symbolic link DIRECTORY It does NOT refer to a sub-tree of the server though the directories the server passes though to reach the alias'ed location is used. EG: will affect the alias Alias /project /student/group/project/www will hav no effect at all if no directory or directory symbolic link for /project exists ------------------------------------------------------------------------------- access control Refer to the URL path to the location, including alias symbolic links etc. Does this override directory considerations? ------------------------------------------------------------------------------- Setting up a Web Password for a Sub-directory See apache_auth_basic.txt And passwd_protect_101.txt ------------------------------------------------------------------------------- Simple HTTPS server Create a certificate and run... openssl s_server -accept 443 -cert mycert.pem -WWW This creates a simple HTTPS server for the current drectory! This is not however recommended as it provides no logging, or permission control. That is not very good sercurity wise. ------------------------------------------------------------------------------- A 3 line perl Webserver! #!/usr/bin/perl # # Usage: webserv.pl {directory} {portnum} # Example: webserv.pl /home/LOGINNAME/public_html 4242 # # Start a webserver on port number 'portnum', where 'directory' is the full # path to the directory you wish to serve. People can then access files in # your directory via "http://machinename:portnum/filename.html". Note that # this three-liner is minimal, and does NOT support: auto-indexing, CGI, SSI, # forms/posting, https, htaccess, or anything else. Essentially it only # supports 'GET', and is intended just as a curiousity. # # Written by Sarang Gupta (sarang@sarangworld.com) # http://www.sarangworld.com/perlscript.php3 # # It can be broken using '..' indexing, and does not underatnd URI escapes. # It also fails with HTTP/1.0 protocol which includes the web server being # looked at (proxying). # -- Anthony Thyssen use Socket;($pr,$pt)=@ARGV;socket(S,PF_INET,SOCK_STREAM,getprotobyname("tcp")); $stat=bind(S,sockaddr_in($pt,INADDR_ANY))||die;listen(S,SOMAXCONN); for(;accept(C,S);){while(){if(/get (\S+)/i){print C `cat $pr/$1`;last}}} ------------------------------------------------------------------------------- Serve current directory on port 8080 (using Shell and "nc") :;while [ $? -eq 0 ];do nc -vlp 8080 -c'(r=read;e=echo;$r a b c;z=$r;while [ ${#z} -gt 2 ];do $r z;done;f=`$e $b|sed 's/[^a-z0-9_.-]//gi'`;h="HTTP/1.0";o="$h 200 OK\r\n";c="Content";if [ -z $f ];then($e $o;ls|(while $r n;do if [ -f "$n" ]; then $e "`ls ]-gh $n` ]";fi;done););elif [ -f $f ];then $e "$o$c-Type: `file -ib $f`\n$c-Length: ]`stat -c%s $f`";$e;cat $f;else $e -e "$h 404 Not Found\n\n404\n";fi)';done ] From Tip #445 www.shell-fu.org ------------------------------------------------------------------------------- Server Moved - Fake Web server! Create a tail script of a static document to output and create a inetd entry to call this document on ANY web server access! In /etc/services add... =======8<-------- www 80/tcp httpd # WorldWideWeb server =======8<-------- In /etc/inetd.conf add... =======8<-------- www stream tcp nowait nobody /opt/etc/httpd_moved =======8<-------- Now create the /opt/etc/httpd_moved script with the message to output... =======8<-------- #!/usr/bin/tail -n+4 # # Fake inetd http script which just reports that the server has moved! # HTTP/1.1 200 OK Server: Fake_Tail_Server/1.0 (Unix) Last-Modified: Mon, 6 Jul 1998 02:36:39 GMT Connection: close Content-Type: text/html ....whatever message is required.... =======8<-------- An example script is called "httpd_moved.sh" in this directory. Make sure the above is executable, then to enable the above HUP the inetd daemon to get it to re-read its config file. ------------------------------------------------------------------------------ VHost Redirection without changing DNS. A Proxy server is just a web server. As such you can also use it to test what it will do with a VHost request. But only for non-HTTPS protocol! For example Set up an apache webserver has... ServerName www.domain ServerAlias hostname.domain ServerAlias www.alt-domain ServerAlias hostname.alt-domain Redirect permanent / http://www.domain/ Test with curl --head --proxy server-under-test:80 www.domain HTTP/1.1 301 Moved Permanently ... Location: http://www.domain/ ... -------------------------------------------------------------------------------