轻量级HTTP服务器反向代理

3
我在Apache的httpd.conf文件中设置了反向代理:
ProxyPass "/endpoint" "https://someurl.com/endpoint"
ProxyPassReverse "/endpoint" "https://someurl.com/endpoint"

我需要在 Lighttpd 中复制这个功能。我正在运行一个 JS 应用程序,它调用 localhost:8080/endpoint 来检索一些数据。我想设置一个代理来始终/endpoint 重定向到 https://someurl.com/endpoint

在我的 lighttpd.conf 文件中,我有以下设置:

server.modules = ("mod_proxy")

$HTTP["url"] =~ "^.*endpoint" {
  proxy.server = ( "" => (( "host" => "https://someurl.com/endpoint" ) ) )
}

基于这篇SO答案,我也尝试了以下方法:

server.modules = ("mod_proxy")
proxy.server = ( "/endpoint" => (( "host" => "https://someurl.com/endpoint" )))

基于lighttpd文档
无论哪种情况,我仍在访问localhost:8080/endpoint,结果是404错误。如何正确设置代理?
1个回答

4
在lighttpd 1.4.46及以上版本中,您可以使用proxy.header。请参见https://redmine.lighttpd.net/projects/lighttpd/wiki/Docs_ModProxy
server.modules = ("mod_proxy")
$HTTP["url"] == "/endpoint" {
    proxy.server = ( "" => (( "host" => "someurl.com" )))
    proxy.header = ( "map-host-request" => ( "-" => "someurl.com"),
                     "map-host-response" => ("-" => "-"))
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接