Author Topic: SBHTTPD  (Read 16639 times)

btechint

  • Guest
SBHTTPD
« on: January 25, 2008, 12:59:11 PM »
When I:

SBHTTPD -start

After a short while this error:

d:\sb\source\examples\sibawa\sibawastart.bas(0): error &H44:The file can not be read.

------------

This is on a clean-new install, winxp. I installed at: d:\sb

There are no directories in the source dir.

\examples is:
 sb\examples

there is no \sibawa
there is no
sibawastart.bas

----------

My guess is that the config file in the bin dir has info error?

My main area of learning is in trying to get the http engine working, and then getting a server working with the http engine. I need to run cgi perl scripts locally to build database files.

thanks, John

note; this is on an windows xp system

Support

  • Administrator
  • *****
  • Posts: 22
    • View Profile
SBHTTPD
« Reply #1 on: January 25, 2008, 02:32:51 PM »
Hi John,

The sibawastart.bas program I believe is part of the authorization extension to Apache and isn't needed to get the application server (sbhttpd) running. Just remove those startup lines in the basic.conf file.

I have three separate sbhttpd servers running on the scriptbasic.net server that work great.

Feel free to send me your basic.conf to have a peek at if you like.

support@scriptbasic.org

John

Support

  • Administrator
  • *****
  • Posts: 22
    • View Profile
SBHTTPD
« Reply #2 on: January 25, 2008, 11:36:36 PM »
To install ScriptBasic (scriba & sbhttpd) on a CentOS 5 (Red Hat recompile), place the Linux files in the following directories.
Code: [Select]

/usr/bin
-rwxr-xr-x 1 root root 508070 Jan 25 21:30 sbhttpd
-rwxr-xr-x 1 root root 482077 Jan 24 19:21 scriba

/usr/lib/scriba
-rwxr-xr-x 1 root root   43894 May 11  2006 cgi.so
-rwxr-xr-x 1 root root 2016573 May 16  2006 curl.so
-rwxr-xr-x 1 root root   18328 May 11  2006 dbg.so
-rwxr-xr-x 1 root root  738419 May 11  2006 gd.so
-rwxr-xr-x 1 root root   11024 May 11  2006 hash.so
-rwxr-xr-x 1 root root   22367 Jul 24  2007 mt.so
-rwxr-xr-x 1 root root   21646 Jan 17 23:18 mysql.so
-rwxr-xr-x 1 root root  454982 May 11  2006 odbc.so
-rwxr-xr-x 1 root root   31223 May 16  2006 pgsql.so
-rwxr-xr-x 1 root root  358109 May 11  2006 psql.so
-rwxr-xr-x 1 root root   51669 May 11  2006 re.so
-rwxr-xr-x 1 root root   10581 May 11  2006 t.so
-rwxr-xr-x 1 root root    2772 May 11  2006 ux.so
-rwxr-xr-x 1 root root  595207 May 11  2006 zlib.so

/usr/include/scriba
-rw-r--r-- 1 root root 5438 May 11  2006 cgi.bas
-rw-r--r-- 1 root root  731 May 16  2006 curl.bas
-rw-r--r-- 1 root root  721 May 11  2006 dbg.bas
-rw-r--r-- 1 root root 8331 May 11  2006 error.bas
-rw-r--r-- 1 root root 2274 May 11  2006 gd.bas
-rw-r--r-- 1 root root 2028 May 11  2006 hash.bas
-rw-r--r-- 1 root root  214 May 11  2006 heb.bas
-rw-r--r-- 1 root root 9968 May 11  2006 modinst.bas
-rw-r--r-- 1 root root 1178 Jul 24  2007 mt.bas
-rw-r--r-- 1 root root   10 May 11  2006 my.bas
-rw-r--r-- 1 root root 1709 May 11  2006 mysql.bas
-rw-r--r-- 1 root root  590 May 11  2006 odbc.bas
-rw-r--r-- 1 root root 1592 May 16  2006 pgsql.bas
-rw-r--r-- 1 root root 2119 May 11  2006 re.bas
-rw-r--r-- 1 root root  945 May 11  2006 t.bas
-rw-r--r-- 1 root root  578 May 11  2006 time.bas
-rw-r--r-- 1 root root  551 May 11  2006 ux.bas
-rw-r--r-- 1 root root  997 May 11  2006 zlib.bas

/etc/scriba
-rw-r--r-- 1 root root 1682 Jan 25 20:37 basic.conf
-rw-r--r-- 1 root root 1102 Jan 25 20:35 basic.conf.txt

/var/log/scriba
-rw-r--r-- 1 root root 1626 Jan 25 21:32 app.log
-rw-r--r-- 1 root root    0 Jan 25 20:34 err.log
-rw-r--r-- 1 root root  976 Jan 25 21:33 hit.log
-rw-r--r-- 1 root root    0 Jan 25 20:30 panic.log
-rw-r--r-- 1 root root    5 Jan 25 21:32 pid.txt
-rw-r--r-- 1 root root    0 Jan 25 20:34 start.log

Note: Create empty log files to get started.


Here is a 'bare bones' basic.conf file for both scriba and sbhttp under CentOS 5.
Code: [Select]

dll ".so"
module "/usr/lib/scriba/"
include "/usr/include/scriba/"
preproc (
  internal (
    dbg "/usr/lib/scriba/dbg.so"
   )
 )
maxstep 0
maxlocalstep 0
maxlevel 55440
maxmem 0
servers (
  server (
    port 8080
    ip "127.0.0.1"
    protocol "http"
   )
  threads 1024
  listenbacklog 3
  home "/var/www/html/app-bin/"
  proxyip 1
  pid (
    file "/var/log/scriba/pid.txt"
    delay 10
    wait (
      period 10
      length 1
     )
   )
  errmsgdest 3
  nolog 0
  log (
    panic (
      file "/var/log/scriba/panic.log"
     )
    app (
      file "/var/log/scriba/app.log"
     )
    err (
      file "/var/log/scriba/err.log"
     )
    hit (
      file "/var/log/scriba/hit.log"
     )
    stat (
      file "/var/log/scriba/stat.log"
     )
   )
  msg404 """

Error 404 page not found

Page not found
We regretfully inform you that the page you have requested can not be found
on this server.

In case you are sure that this is a server configuration error, please
contact the site administrator.

"""
  code404 "200 OK"
 )


The ScriptBasic interpreter and application server both use the same compiled configuration file. Maintain your basic.conf.txt file in a text editor. Next convert it to the binary format ScriptBasic uses by typing the following command at a console prompt in the /etc/scriba directory.

scriba -k basic.conf.txt


At a minimal, make sure these proxy modules are enabled.
Code: [Select]

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so


Here is what I added to the end of Apache's httpd.conf file.
Code: [Select]

# ScriptBasic Application Server
ProxyPass /app-bin/ http://127.0.0.1:8080/
ProxyPassreverse /app-bin/ http://127.0.0.1:8080/


You can optionally set the SCRIBACONF environment variable to the full path and filename of where your basic.conf file is located and named. (/etc/scriba/basic.conf is the default location and name if the ScriptBasic environment variable isn't set)

After restarting Apache for the proxy addition, enter the following at a console prompt.

sbhttpd -start

All requests to the /app-bin directory are sent to the ScriptBasic application server to be process.

To stop the server, kill -9 the process ID # in the pid.txt file.

John

Support

  • Administrator
  • *****
  • Posts: 22
    • View Profile
SBHTTPD
« Reply #3 on: January 26, 2008, 01:50:53 AM »
You can expand your application directory structure and hide it's files behind the web root directory. The "/var/www/html/app-bin" directory is the interface between Apache and sbhttpd. It doesn't have to contain any files if you use the ScriptBasic "vdirs" feature.
Code: [Select]

  vdirs (
    dir "/client/:/var/www/private/"
   )


http://sb.dev/app-bin/echo.bas   <-- this will run echo.bas in the webroot /app-bin (if you prefer, the 'home' directory can be defined below webroot , another drive, ... which allows for virtual mapping of your script resources.)

http://sb.dev/app-bin/client/echo.bas  <-- this runs the client version of the program located below the webroot in the private directory
Code: [Select]

Partial echo.bas output:

ServerSoftware  = ScriptBasic Application Server 2.1.1
ServerName      = undef
GatewayInterface= CGI/1.1
ServerProtocol  = HTTP/1.1
ServerPort      = 80
RequestMethod   = POST
PathInfo        = undef
PathTranslated  = /var/www/private/echo.bas
ScriptName      = echo.bas
QueryString     =
RemoteHost      = 192.168.1.101
RemoteAddress   = 192.168.1.101
AuthType        = undef
RemoteUser      =
RemoteIdent     = undef
ContentType     = application/x-www-form-urlencoded
ContentLength   = 44
UserAgent       = Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11
Cookie          = cookie1=1; cookie2=2; cookie3=3
Referer         = http://sb.dev/app-bin/client/echo.bas
Password        =
Full auth string= undef

Code: [Select]

/var/www/
drwxr-xr-x  4 root      root 4096 Jan 15 17:36 cgi-bin
drwxr-xr-x  3 root      root 4096 Jan 25 02:47 error
drwxr-xr-x  3 root      root 4096 Jan 25 20:13 html
drwxr-xr-x  3 root      root 4096 Jan 25 02:47 icons
drwxr-xr-x 14 root      root 4096 Jan 25 02:47 manual
drwxr-xr-x  2 root      root 4096 Jan 26 18:20 private
drwxr-xr-x  2 webalizer root 4096 Jan 25 02:47 usage

/var/www/html/
drwxr-xr-x 2 root root 4096 Jan 26 18:20 app-bin

/var/www/html/app-bin/
-rw-r--r-- 1 root root 4068 Jan 26 01:33 echo.bas

/var/www/private/
-rw-r--r-- 1 root root 4068 Jan 26 06:32 echo.bas


John

Support

  • Administrator
  • *****
  • Posts: 22
    • View Profile
SBHTTPD
« Reply #4 on: January 26, 2008, 02:20:41 AM »
If you prefer not to expose your database host, login, password and db_name with the mysql::RealConnect() function, you can define this in the basic.conf file and use the mysql::Connect("accounting") function instead.
Code: [Select]

;
; MySQL configuration
;
mysql (
  connections (
    accounting (  ; the name of the connection
    host "127.0.0.1"  ; the host for the connection
    db "acct"  ; database for the connection
    user "db_user_id"  ; user for the connection
    password "db_password"  ; password for the connection
    port 3306  ; the port to use
    socket ""  ; the name of the socket or ""
    flag 0  ; the client flag
    clients 10  ; how many clients to serve before really closing the connections
    )
  )
 )



John

Support

  • Administrator
  • *****
  • Posts: 22
    • View Profile
SBHTTPD
« Reply #5 on: January 26, 2008, 02:28:47 AM »
Code: [Select]

client (
    allowed "127.0.0.1/255.255.255.255"
    allowed "16.94.58.4/0.0.0.0"

    denied "127.0.0.1/0.0.0.0"
    denied "16.192.68.5/255.255.0.0"
    )


Quote from: "Peter Verhas"

You can define the client IPs that are allowed and denied to connect to the engine. This is the real client that is connecting to the listener on the socket and trying to get access via HTTP and not the client reported by any proxy header field. You can use this configuration option to allow only the web server machine to connect to the engine via the proxy module and disallow all external connections that may try to connect from external machines. You can also use this option to configure a client application not to be accessed by external computer.

A connection is accepted by the engine if there is at least one allowed configuration line that allows the connection and there is no any denied configuration line that denies the connections.

The string following the keywords allowed or denied should contains the IP number and the MASK separated by a slash. When the client IP is calculated first it is bitwise AND-ed by the MASK and compared to the IP number. Thus

allowed "127.0.0.1/255.255.255.255"

allows only connections from the localhost and

denied "127.0.0.1/0.0.0.0"

denies access for no-one (in other word this line is waste of CPU and text file, but is good as an example). The line

denied "16.192.68.5/255.255.0.0"

disallows all requests that come from an IP number 16.192.*.* that is some internal sub-network of the once existed firm: Digital Equipment Corporation.


The ScriptBasic application server gives you the flexibility to extend your reach to other system facilities but gives you the means to protect your site from unwanted external activity. (web and intranet environments)

And finally to answer your original question.

Code: [Select]

' sibawastart.bas
'
' This program is started by the SIBAWA system when the application starts.
'
' This program loads the cache authentication and access control into memory
' and also maintains the session data handling session time outs.


This feature manages the directory .htaccess authentication and caches it. Peter has included session handling support and a browser based management interface to setup users and access levels.

Quote
If you have information on your web site that is sensitive, or intended for only a small group of people, the techniques in this tutorial will help you make sure that the people that see those pages are the people that you wanted to see them.

Apache Authentication, Authorization, and Access Control

(One of the ScriptBasic gifts I haven't opened yet.  :wink: )

btechint

  • Guest
sbhttp
« Reply #6 on: January 26, 2008, 10:49:38 AM »
I was able to get sbhttd working. I had questions about the ip allow-disallow, but your help notes answered them. I was also wondering about the pid.txt. A problem I have now is that the sbhttd will not stop. I have tried
sbhttd stop
sbhttd -stop
I see that I can use kill [-pid (number)]. Not sure yet what that is or how to use it.

Here is what I did. Edited the scriba.conf.lsp file so everything pointed to my dir's. Deleted the sibawa references. Changed the ip list to;
allowed "127.0.0.1/255.255.255.255"
port 80

Made a new scriba.conf using:

scriba -k scriba.conf.lsp

When I enter:

sbhttd -start

The example files load and seem to work.

sbhttp -install

seems to work

Being a complete newb, have some concern about leaving my system open the scrupulous from the net, will have to figure out the IP thing.

Thanks

Support

  • Administrator
  • *****
  • Posts: 22
    • View Profile
SBHTTPD
« Reply #7 on: January 26, 2008, 03:55:31 PM »
Quote

I was able to get sbhttd working. I had questions about the ip allow-disallow, but your help notes answered them. I was also wondering about the pid.txt. A problem I have now is that the sbhttd will not stop. I have tried
sbhttd stop
sbhttd -stop
I see that I can use kill [-pid (number)]. Not sure yet what that is or how to use it.


The pid.txt file contains the main active process ID for sbhttpd. Just cat the file, get the number and kill -9 ####.

You can delete the pid.txt file and sbhttpd will die on it's own. (it may take a minute due to running threads need to finish)

Good to hear you got it going !

John

Support

  • Administrator
  • *****
  • Posts: 22
    • View Profile
SBHTTPD
« Reply #8 on: January 27, 2008, 01:00:21 AM »
Quote from: "btechint"

note; this is on an windows xp system


Sorry about that. Well at least you'll know how to install it on a Linux box when your ready. :)

Here is my local XP / Apache basic.conf file as an example.

Code: [Select]

; ScriptBasic sample configuration file
;
; Note that this configuration file format is from v1.0b19 or later and has to be compiled
; to internal binary format before starting ScriptBasic

; this is the extension of the dynamic load libraries on this system
dll ".dll"

; where the modules are to be loaded from
module "C:/scriptbasic/\\modules\\"

; where to search system and module include files
; trailing / or \ is needed
include "C:/scriptbasic/\\include\\"

; this is where modules should install their documentation
docu "C:/scriptbasic/\\doc\\"

; the maximum number of includes that script basic processes
; this will stop the reading when the programmer makes error
; and includes files recursively. 1000 is the default value
maxinclude 100

;
; define preprocessors
;
preproc (
  internal (
    dbg "C:/scriptbasic/\\modules\\dbg.dll"
    )
  )
;
; LIMIT VALUES TO STOP INIFINITE LOOP
;

; the maximal number of steps allowed for a program to run
; comment it out or set to zero to have no limit
maxstep 0

; the maximal number of steps allowed for a program to run
; inside a function.
; comment it out or set to zero to have no limit
maxlocalstep 0

; the maximal number of recursive function call deepness
; essentially this is the "stack" size
maxlevel 300


; the maximal memory in bytes that a basic program is allowed to use
; for its variables
maxmem 0

;
; This is the directory where we store the compiled code
; to automatically avoid recompilation
;
; cache "C:/scriptbasic/\\cache\\"

cgi (
;
; These are the keys used by the CGI module
;
  debugfile "C:/scriptbasic/\\cgidebug.txt"
  )

;
; MySQL configuration
;
mysql (
  connections (
    ABC (             ; the name of the connection
    host "127.0.0.1"     ; the host for the connection
    db "db_abc"             ; database for the connection
    user "dbadmin"          ; user for the connection
    password "dbpw" ; password for the connection
    port 3306            ; the port to use
    socket ""            ; the name of the socket or ""
    flag 0               ; the client flag
    clients 10           ; how many clients to serve before really closing the connections
    )
  )
 )
;
; Configure the simple ScriptBasic httpd daemon
;
; Note that scripts may change the working directory therefore
; all directories should be specified here full path. For example
; the directory names here do not include the drive c: or e:
; because I develop it on two machines and it was inconvenient
; to alter and recompile the config file each time I moved the
; source to the other machine. When I run a script that changes
; the drive the http daemon stops in a few seconds because the
; guard thread do not find the pid file and therefore tells the
; engine to stop.
;
servers (
  server (
    port 8080
    ip "127.0.0.1"
    protocol "http"
   )
  threads 1024
  listenbacklog 3
  home "C:\\Program Files\\Apache Software Foundation\\Apache2.2\\htdocs\\app\\"
  proxyip 1
  pid (
    file "C:/scriptbasic/\\httpdlog\\pid.txt"
    delay 60
    wait (
      period 10
      length 1
     )
   )
  vdirs (
    dir "/sb/:C:\\Program Files\\Apache Software Foundation\\Apache2.2\\htdocs\\app\\sb\\"
    dir "/fts/:C:\\Program Files\\Apache Software Foundation\\Apache2.2\\htdocs\\app\\fts\\"
    dir "/nwmls/:C:\\Program Files\\Apache Software Foundation\\Apache2.2\\htdocs\\app\\nwmls\\"
    )

  errmsgdest 3
  nolog 1 ; set this true not to use logs or ignore erroneouslog configuration
  log (
    panic ( file "C:/scriptbasic/\\httpdlog\\panic.log" )
    app   ( file "C:/scriptbasic/\\httpdlog\\app.log" )
    err   ( file "C:/scriptbasic/\\httpdlog\\err.log" )
    hit   ( file "C:/scriptbasic/\\httpdlog\\hit.log" )
    stat  ( file "C:/scriptbasic/\\httpdlog\\stat.log" )
    )
  ; the error page when a page is not found
msg404 """
<HTML>
<HEAD>
<TITLE>Error 404 page not found</TITLE>
</HEAD>
<BODY>
<FONT FACE="Verdana" SIZE="2">
<H1>Page not found</H1>
We regretfully inform you that the page you have requested can not be found on this server.
<p>
In case you are sure that this is a server configuration error, please contact
<FONT SIZE="3"><TT>root@localhost</TT></FONT>
</FONT>
</BODY>
</HTML>
 """
  code404 "200 OK" ; the http error code for page not found. The default is 404
  ; the program to run when a page is not found
  ;run404 "C:/scriptbasic/\\source\\examples\\run404.bas"
  )


John