recently I was asked, how a minimalist Pi3Web Server can be packaged
in order to run it automatically from CD/DVD-ROM on a Win32 target system.
I assumed for the simpliest possible use case:
- no administration GUI
- only static HTML
- no access log
- launched automatically from read only medium (no absolute paths, no error log)
- server bound to localhost/127.0.0.1
The corner marks of the solution are:
- use Internet.pi3 instead of Config.pi3
- remove access log, absolute paths etc. from configuration
- launch server with Pi3Win32.exe instead of EnhPi3.exe
- remove all unused binary and other file resources
This is the list of all retained files (icons not listed here, total size less than 600kB).
\Pi3Web\WebRoot\favicon.ico
\Pi3Web\WebRoot\index.htm
\Pi3Web\bin\PiAPI.dll
\Pi3Web\bin\Icons.dll
\Pi3Web\bin\PIIO.dll
\Pi3Web\bin\Pi3Win32.exe
\Pi3Web\bin\PIServer.dll
\Pi3Web\bin\Pi3API.dll
\Pi3Web\bin\Pi2API.dll
\Pi3Web\bin\http.dll
\Pi3Web\Icons\[...]
\Pi3Web\Fragment\500.htm
\Pi3Web\Fragment\416.htm
\Pi3Web\Fragment\404.htm
\Pi3Web\Fragment\501.htm
\Pi3Web\Fragment\304.htm
\Pi3Web\Fragment\400.htm
\Pi3Web\Fragment\401.htm
\Pi3Web\Fragment\403.htm
\Pi3Web\Fragment\Mime.typ
\Pi3Web\Fragment\301.htm
\Pi3Web\Conf\Pi3API.cnf
\Pi3Web\Conf\HTTP.cnf
\Pi3Web\Conf\IO.cnf
\Pi3Web\Conf\Server.cnf
\Pi3Web\Conf\Internet.pi3
This ist the contents of configuration file Internet.pi3:
include ../Conf/IO.cnf
include ../Conf/Server.cnf
include ../Conf/Pi3API.cnf
include ../Conf/HTTP.cnf
<Object>
Name ServerIOObject
Class TCPIPIOClass
Type Passive
BindHost localhost
BindPort 80
AcceptTimeout -1
RecvTimeout 60
SendTimeout 45
PeerIPVariable STRING:RemoteAddr
PeerHostNameVariable STRING:RemoteHost
LocalAddressVariable STRING:LocalAddr
ServerPortVariable RFC822:ServerPort
Flags OwnDB|SetPeerAddress|DNSReverseLookup|SetLocalAddress
AcceptLockFile "../Logs/lockfile.txt"
</Object>
<Object>
Name MainVirtualHostInformation
Class VirtualHostClass
Administrator webmaster@localhost
HostName localhost
</Object>
<Object>
Name ThreadPoolDispatcher
Class MTMIOServerClass
IOObject ServerIOObject
LogicObject HTTPLogicObject
MaxThreads 10
ExitAfter 1000
</Object>
<Object>
Name Main
Class UNIXDaemonClass
ServerObject ThreadPoolDispatcher
PIDFile "../Logs/pid.log"
RLimitCpu Maximum
LockFileName "../Logs/lockfile.txt"
Message "Pi3Web HTTP Server Started"
NumberOfProcesses 8
</Object>
Hello,
recently I was asked, how a minimalist Pi3Web Server can be packaged
in order to run it automatically from CD/DVD-ROM on a Win32 target system.
I assumed for the simpliest possible use case:
- no administration GUI
- only static HTML
- no access log
- launched automatically from read only medium (no absolute paths, no error log)
- server bound to localhost/127.0.0.1
The corner marks of the solution are:
- use Internet.pi3 instead of Config.pi3
- remove access log, absolute paths etc. from configuration
- launch server with Pi3Win32.exe instead of EnhPi3.exe
- remove all unused binary and other file resources
This is the list of all retained files (icons not listed here, total size less than 600kB).
\Pi3Web\WebRoot\favicon.ico
\Pi3Web\WebRoot\index.htm
\Pi3Web\bin\PiAPI.dll
\Pi3Web\bin\Icons.dll
\Pi3Web\bin\PIIO.dll
\Pi3Web\bin\Pi3Win32.exe
\Pi3Web\bin\PIServer.dll
\Pi3Web\bin\Pi3API.dll
\Pi3Web\bin\Pi2API.dll
\Pi3Web\bin\http.dll
\Pi3Web\Icons\[...]
\Pi3Web\Fragment\500.htm
\Pi3Web\Fragment\416.htm
\Pi3Web\Fragment\404.htm
\Pi3Web\Fragment\501.htm
\Pi3Web\Fragment\304.htm
\Pi3Web\Fragment\400.htm
\Pi3Web\Fragment\401.htm
\Pi3Web\Fragment\403.htm
\Pi3Web\Fragment\Mime.typ
\Pi3Web\Fragment\301.htm
\Pi3Web\Conf\Pi3API.cnf
\Pi3Web\Conf\HTTP.cnf
\Pi3Web\Conf\IO.cnf
\Pi3Web\Conf\Server.cnf
\Pi3Web\Conf\Internet.pi3
This ist the contents of configuration file Internet.pi3:
include ../Conf/IO.cnf
include ../Conf/Server.cnf
include ../Conf/Pi3API.cnf
include ../Conf/HTTP.cnf
<Object>
Name ServerIOObject
Class TCPIPIOClass
Type Passive
BindHost localhost
BindPort 80
AcceptTimeout -1
RecvTimeout 60
SendTimeout 45
PeerIPVariable STRING:RemoteAddr
PeerHostNameVariable STRING:RemoteHost
LocalAddressVariable STRING:LocalAddr
ServerPortVariable RFC822:ServerPort
Flags OwnDB|SetPeerAddress|DNSReverseLookup|SetLocalAddress
AcceptLockFile "../Logs/lockfile.txt"
</Object>
<Object>
Name MainVirtualHostInformation
Class VirtualHostClass
Administrator webmaster@localhost
HostName localhost
</Object>
<Object>
Name ThreadPoolDispatcher
Class MTMIOServerClass
IOObject ServerIOObject
LogicObject HTTPLogicObject
MaxThreads 10
ExitAfter 1000
</Object>
<Object>
Name Main
Class UNIXDaemonClass
ServerObject ThreadPoolDispatcher
PIDFile "../Logs/pid.log"
RLimitCpu Maximum
LockFileName "../Logs/lockfile.txt"
Message "Pi3Web HTTP Server Started"
NumberOfProcesses 8
</Object>
<Object>
Name Default
Class FlexibleHandlerClass
Init ReturnCode ReturnCode="COMPLETED"
Headers ReadRequestHeaders
HostMap ReturnCode ReturnCode="COMPLETED"
Mapping MapToErrorDocument \ IgnoreStatus="0 200" \ DefaultMessage="/errors/unknown.htm" \ 301="/errors/301.htm" \ 304="/errors/304.htm" \ 400="/errors/400.htm" \ 401="/errors/401.htm" \ 403="/errors/403.htm" \ 404="/errors/404.htm" \ 500="/errors/500.htm" \ 501="/errors/501.htm"
Mapping PathMapper From="/errors/" To="Fragment/"
Mapping PathMapper From="/icons/" To="Icons/"
Mapping PathMapper From="/" To="WebRoot/"
CheckPath DirectoryExists IndexFile="index.html" \ IndexFile="index.htm" IndexFile="Index.html" IndexFile="Index.htm"
CheckPath RefuseFileByMask AllowFileMask="EF" RefuseStatus=404
CheckPath RefuseFileByMask AllowFileMask="F" RefuseStatus=403
CheckPath ReturnCode ReturnCode=COMPLETED
CheckAuth ReturnCode ReturnCode=COMPLETED
CheckAccess AccessByFile RequirePermissions="R"
CheckType Condition="¬(&or(&cmpi($m,GET),&cmpi($m,HEAD)))" \ StatusCode StatusCode="501"
CheckType ConditionalGet
CheckType CheckForDirectory SetType="internal/x-directory"
CheckType MIMETypeByExtension
CheckType ReturnCode ReturnCode="COMPLETED"
Handle Condition="¬(®exp('internal/*',$c))" SendFile
Handle StatusCode StatusCode="404"
</Object>
<Object>
Name HTTPLogicObject
Class HTTPDispatcherClass
Handlers Default
KeepOpen On
ServerRoot ./../
ServerStamp Pi3Web/2.0.3
DefaultHost MainVirtualHostInformation
MIMEFile "Fragment/Mime.typ"
DefaultMIMEType "application/octet-stream"
ErrorLogFile "NUL"
</Object>
This is how the server is started from the target drive:
>cd /Pi3Web/bin
>Pi3Win32.exe ../Conf/Internet.pi3
--
kind regards,
Holger