📄 proxy.pi3
字号:
#!Pi3
# ===
#
# Top level configuration file
#
# ===
# Include standard IO and server stuff
include ../Conf/IO.cnf
include ../Conf/Server.cnf
include ../Conf/Pi3API.cnf
# ---
#
# IO Object for main listening socket.
#
# ---
<Object>
Name ServerIOObject
Class TCPIPIOClass
Type Passive
# A hostname must be specified for the Pi3Web HTTP server. The hostname
# will be used by the server lookup the IP address that this server will
# listen on. A value of INADDR_ANY let the server listen on any IP address.
BindHost localhost
# A TCP port must be specified for this HTTP server. The TCP port
# is the port that the HTTP will listen for requests on. This is
# typically 80 for HTTP servers.
#
# Note that UNIX operating systems normally require that the server
# initially run as user 'root' to bind on ports between 0 and 1024
# BindPort 80 leave an HTTP origin server run on 80 use something non
# standard - like:
BindPort 1888
# Timeout accepting connections. -1 specifies no timeout.
AcceptTimeout -1
# Specify timeout for sending data. -1 specifies no timeout.
RecvTimeout 60
# Specify timeout for receiving data. -1 specifies no timeout.
SendTimeout 45
PeerIPVariable STRING:RemoteAddr
PeerHostNameVariable STRING:RemoteHost
LocalAddressVariable STRING:LocalAddr
ServerPortVariable RFC822:ServerPort
# Flags
#
# OwnDB - Object adds its own DB, rather than use the parents
# this is necessary to avoid collision of values placed in
# the DB between different connection.
#
# SetPeerAddress - IP address of remote peer with be put
# into the specified variable.
#
# DNSReverseLookup - Use reverse DNS to get the hostname of the
# peer and place it in the specified variable.
#
# SetLocalAddress - Put local address in the specified variable.
Flags OwnDB|SetPeerAddress|DNSReverseLookup|SetLocalAddress
# Pointer to file with lockfile name, to avoid collisions on accept
# with multiple processes
AcceptLockFile "../Logs/lockfile.txt"
</Object>
# ---
#
# Main virtual host object.
#
# ---
<Object>
Name MainVirtualHostInformation
Class VirtualHostClass
# Administrator for the primary virtual host
Administrator webmaster@localhost
# Hostname that this server uses in redirects.
HostName localhost
# Port that the server uses in redirects.
# Specify it only if it is not the standard port for the protocol in
# use, i.e. 80 for HTTP and 443 for HTTPS
# ServerPort 80
</Object>
# ---
#
# Thread dispatch object
#
# This is an instance of MultiThreadedIOServerClass with appropriate
# parameters
#
# ---
<Object>
Name ThreadPoolDispatcher
Class MultiThreadedIOServerClass
# The IOObject is the object that will be used for the listening socket
# it can be a real IOObject (such as TCP/IP), as test IO object which
# feeds stub data into the server or a filter IO object which encrpts
# or logs data passed through it.
#
# Example test IO object:
# IOObject TestIOObject
#
# Log IO to file:
# IOObject SnoopIO IOObject="ServerIOObject" OutFile="./snoop.dbg"
#
IOObject ServerIOObject
# Dispatch accepted IO connection to the HTTPLogicObject
LogicObject HTTPLogicObject
# Number of threads to use
MaxThreads 10
# Number of requests to exit after
ExitAfter 1000
</Object>
# ---
#
# Main Pi3 object.
#
# This is an instance of the UNIXDaemonClass to fork the server into
# one monitor process and 'NumberOfProcesses' child processes.
#
# The monitor process automatically starts a new child processes whenever
# a child process exits.
#
# ---
<Object>
Name Main
Class UNIXDaemonClass
# Actual class to accept new IO requests and dispatch them
ServerObject ThreadPoolDispatcher
PIDFile "../Logs/pid.log"
RLimitCpu Maximum
# User that child processes will run as. Server must run as root to
# be able to change to the specified user. A user id number can be
# specified with #number. Server which start with root privileges should
# change to a user id with lesser privileges for security reasons.
# User nobody
# Group that child processes will run as. Server must run as root to
# be able to change to a different group. A group id number can be
# specified with #number.
# Group #-1
# generate a server unique lockfile name and write it into
# Logs/lockfile.txt
LockFileName "../Logs/lockfile.txt"
# Message to write just before the server is ready to start accepting
# connections.
# default
Message "Pi3Web HTTP Server Started"
# Specify the number of processes.
NumberOfProcesses 8
</Object>
# ===
#
# Proxy.pi3
#
# HTTP Caching proxy server
#
# - The caching proxy server requires external processes
# to cleanup and/or expire items in the cache.
#
# ===
#
# Load library definitions for classes used here.
#
include ../Conf/HTTP.cnf
# ---
#
# HandleCachingProxy
#
# Instance of BasicProxyClass configured to handle requests as an HTTP
# caching proxy server
#
# ---
<Object>
Name HandleCachingProxy
Class BasicProxyClass
# IO object to make proxy requests
IOObject ProxyIOObject
# for debugging a snoop IO object can be inserted in the IO
# request/response chain to generate a logfile. Comment out the
# previous line and uncomment this one.
# IOObject SnoopIO IOObject="ProxyIOObject" OutFile="./proxyio.dbg"
# Specifying 'CacheRoot' turns on caching
# Caching is still under development (its a little buggy and incomplete)
# so this default configuration will not use it.
# CacheRoot "./Cache"
</Object>
# ---
#
# AccessLogger
#
# An instance of ExpressionLoggerClass configured to generate an
# logfile
#
# ---
<Object>
Name AccessLogger
Class ExpressionLoggerClass
#
# Append
#
OpenMode "a"
#
# Line to log
Expression "$A $h - [$t] \"$r\" $s $b$M"
</Object>
# ---
#
# CachingProxy
#
# Sequence of handlers for HTTP Caching Proxy
#
# ---
<Object>
Name CachingProxy
Class FlexibleHandlerClass
Init ReturnCode ReturnCode=COMPLETED
Headers ReadRequestHeaders
#
# Middle phases do not apply to a proxy request
#
HostMap ReturnCode ReturnCode=COMPLETED
Mapping ReturnCode ReturnCode="COMPLETED"
CheckPath ReturnCode ReturnCode="COMPLETED"
CheckAuth ReturnCode ReturnCode="COMPLETED"
CheckAccess ReturnCode ReturnCode="COMPLETED"
CheckType ReturnCode ReturnCode="COMPLETED"
#
# Handle the request with the proxy handler the status is 0
# (request was not previously handled).
# Otherwise fall through to the error case.
#
Handle Condition="&or(&cmp($s,0),&cmp($s,200))" HandleCachingProxy
#
# If we got here an error occurred.
Handle SendErrorMessage DefaultMessage="Fragment/500-gw.htm"
#
# Logging, write a gateway logfile, comment this line out to avoid
# generating this logfile
Log AccessLogger File="Logs/gateway.txt"
Log ReturnCode ReturnCode=COMPLETED
</Object>
# ---
#
# ProxyIOObject
#
# IOObject for communicating with remote HTTP server. This uses
# the TCP/IP transport.
#
# ---
<Object>
Name ProxyIOObject
Class TCPIPIOClass
Type Active
RecvTimeout 60
SendTimeout 60
</Object>
# ---
#
# HTTPLogicObject
#
# HTTP Logic object, dispatches requests to all other handlers
#
# ---
<Object>
Name HTTPLogicObject
Class HTTPDispatcherClass
Handlers CachingProxy
KeepOpen On
ServerRoot ./../
ServerStamp Pi3Web/2.0.3
DefaultHost MainVirtualHostInformation
ErrorLogFile "Logs/error.txt"
# Specifying a file for DebugLogFile effectively turns on debugging
# DebugLogFile "Logs/debug.txt"
#
# The following to directives specify expressions to be logged
# before and after each handler execution respectively.
# The expression as given logs process/thread and handler context
# information indented to the nested handler level.
#
# Timing information is also given for performance tuning.
#
# This logging information is EXTREMELY verbose. Don't even
# think about using it in a production server
#
DebugBeforeHandler "[$P:$k] &align(,$X)&align(,$X) |--> $T \
-------- &align($N,12) &align($R,12) $n \"$r\" $s"
DebugAfterHandler "[$P:$k] &align(,$X)&align(,$X) |<-- $T \
&align($D,8) &align($N,12) &align($R,12) $n \"$r\" $s"
</Object>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -