apache服务器设置了反向代理后,运行一段时间就会莫名其妙的报后台服务器暂时无法连接的错误,过几秒钟后又能自动恢复,查看后发现apache的错误日志中有如下字样:
[error] (OS 10048)Only one usage of each socket address (protocol/network address/port) is normally permitted. : proxy: HTTP: attempt to connect to localhost:8080 (localhost) failed
[error] ap_proxy_connect_backend disabling worker for (host name)
此问题是由于windows环境下缺省的tcp的maxuserport为5000,而使用了反向代理则很可能很快耗尽了端口资源,一旦耗尽端口资源则产生os 10048错误,接着ap_proxy_connect_backend就自动重启所有的线程。
解决办法是到注册表中建立一个maxuserport键以修改此参数的缺省值。以下是msdn上对于此参数的解释:
MaxUserPort
HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters
Data type | Range | Default value |
---|---|---|
REG_DWORD | 5,000–65,534 ( port number ) | 5000 |
Description
Determines the highest port number TCP can assign when an application requests an available user port from the system. Typically, ephemeral ports (those used briefly) are allocated to port numbers 1024 through 5000.
Note
Windows 2000 does not add this entry to the registry. You can add it by editing the registry or by using a program that edits the registry.