ReverseProxy
反向代理服务器,企图比拼nginx
Install / Use
/learn @babizhu/ReverseProxyREADME
ReverseProxy
反向代理服务器,企图比拼nginx的反向代理功能
用法
- 修改uri
val bootstrap = DefaultReverseProxyServer.bootstrap()
.withPort(8000)
.withHttpFilter(object : HttpFilterAdapter(){
override fun clientToProxyRequest(httpObject: HttpObject): HttpResponse? {
if (httpObject is HttpRequest) {
httpObject.uri = "/test"//修改uri
}
return null
}
})
bootstrap.start()
- ip黑名单
val bootstrap = DefaultReverseProxyServer.bootstrap()
.withPort(8000)
.withHttpFilter(BlackListFilter())
bootstrap.start()
- 采用ip hash 进行轮询
val bootstrap = DefaultReverseProxyServer.bootstrap()
.withRoutePolice(IpHashPolicy())
.withPort(8000)
bootstrap.start()
- 根据uri进行路由
val bootstrap = DefaultReverseProxyServer.bootstrap()
.withRoutePolice(object : RoutePolicy {
override fun getBackendServerAddress(request: HttpRequest, channel: Channel): InetSocketAddress? {
return when (request.uri()) {
"user" -> InetSocketAddress("user.api.com", 80)
"prouduct" -> InetSocketAddress("product.api.com", 80)
else -> InetSocketAddress("else.api.com", 80)
}
}
})
.withPort(8000)
.withHttpFilter(BlackListFilter())
bootstrap.start()
性能
请点击 .
Related Skills
node-connect
341.6kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
84.6kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
341.6kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
84.6kCommit, push, and open a PR
