在项目国产化适配过程中,使用tonghttpserver进行反向代理时遇到的问题记录一下。
windows下安装tonghttpserver 参照说明文档需要注意的是
一定需要注意斜杠与反斜杠不然httpserver.exe执行会报路径错误导致启动失败。
ths的配置和apache配置类似,如果熟悉apache反向代理的话,可以直接上手配置了。
下面是一个本地8080端口代理本地的8089端口程序的示例,博主用的是TongHttpServer5.0.0.1。
#HTTP port:
Listen 8080
<Proxy balancer://tongSSLCluster>
</Proxy>
#balancer node config
<Location /lbi>
SetHandler balancer-manager
Order Deny,Allow
Deny from all
Allow from localhost
Allow From 192.168.1.0/24
</Location>
#<Location /server-status>
#SetHandler server-status
#Order Deny,Allow
#Deny from all
#Allow from localhost
#Allow From 192.168.1.0/24
#</Location>
Header add Set-Cookie "ROUTEID=.%{BALANCER_WORKER_ROUTE}e; path=/" env=BALANCER_ROUTE_CHANGED
#Header edit Set-Cookie "(?i)^((?:(?!;\s?Secure).)+)$" "$1; Secure"
#Header edit Set-Cookie "(?i)^((?:(?!;\s?HttpOnly).)+)$" "$1; HttpOnly"
<VirtualHost _default_:8080>
#DocumentRoot "C:/THS/mng"
#<Directory C:/THS/mng>
#Order deny,allow
#Allow from all
#</Directory>
#ProxyPassMatch ^(/.*\.jpg)$ !
#ProxyPassMatch ^(/.*\.png)$ !
#ProxyPassMatch ^(/.*\.js)$ !
#ProxyPassMatch ^(/.*\.css)$ !
#ProxyPassMatch ^(/.*\.bmp)$ !
#ProxyPassMatch ^(/.*\.gif)$ !
#ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/opt/TongWeb/THS/mng/$1
#ProxyPass / balancer://tongSSLCluster/ growth=99 maxattempts=0 nofailover=off lbmethod=bybusyness #stickysession=ROUTEID
#ProxyPassReverse / balancer://tongSSLCluster/
ProxyPreserveHost On
ProxyPass /manager http://localhost:8089/manager/
ProxyPassReverse /manager http://localhost:8089/manager/
#server name
ServerName www.test.com:8080
#server administrator
ServerAdmin you@test.com
BandWidthModule Off
ForceBandWidthModule Off
BandWidth all 0
MaxConnection all 0
BandWidthError 503
ExpiresActive On
ExpiresByType image/gif "access plus 1 days"
ExpiresByType image/jpeg "access plus 24 hours"
ExpiresByType image/png "access plus 24 hours"
ExpiresByType image/jpg "access plus 24 hours"
ExpiresByType text/css "now plus 2 hours"
ExpiresByType application/x-javascript "now plus 2 hours"
ExpiresByType application/javascript "now plus 2 hours"
ExpiresByType application/x-shockwave-flash "now plus 2 hours"
ExpiresDefault "now plus 0 minutes"
#gzip
#FilterDeclare COMPRESS CONTENT_SET
#FilterProtocol COMPRESS change=yes;byteranges=no
#FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} = 'text/html'"
#FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} = 'text/css'"
#FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} = 'text/javascript'"
#FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} = 'application/javascript'"
#FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} = 'application/x-javascript'"
#FilterChain COMPRESS
</VirtualHost>
#Error log
ErrorLog "| D:/WorkSoftWare/THS/bin/rotatelogs.exe D:/WorkSoftWare/THS/logs/error_log_%Y%m%d 86400 480"
#Log Level
LogLevel warn
#Log config
#Log Format
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
<IfModule logio_module>
#Log Format
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
</IfModule>
#Custom log
CustomLog "| D:/WorkSoftWare/THS/bin/rotatelogs.exe D:/WorkSoftWare/THS/logs/access_log_%Y%m%d 86400 480" combined
#
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other
# <Directory> blocks below.
#
<Directory />
# Security Settings, Disable OPTIONS
<Limit OPTIONS>
Order deny,allow
Deny from all
</Limit>
AllowOverride none
#Require all denied
Allow from localhost
</Directory>
<IfModule mpm_winnt_module>
ThreadLimit 1920
ThreadsPerChild 64
MaxConnectionsPerChild 0
</IfModule>