reverse-proxy - Lighttpd反向代理

标签 reverse-proxy lighttpd mod-proxy

我在 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" ) ) )
}

基于 this SO answer . 我也试过:

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

基于lighttpd docs .

在这两种情况下,我仍在点击 localhost:8080/endpoint,这会导致 404 错误。如何正确设置代理?

最佳答案

在 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" => ("-" => "-"))
}

关于reverse-proxy - Lighttpd反向代理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48794514/

相关文章:

azure - 如何创建在 Azure 中运行的反向代理?

apache - 在 httpd 代理中保留协议(protocol)

javascript - 脚本在服务器或客户端上运行?

redirect - Lighttpd 将 url 重定向到小写版本

java - Apache mod_proxy 和 Tomcat 出现 Bad Gateway 502 错误

linux - 哪个负载均衡器的性能更好 mod_jk 或 mod_proxy 或任何其他开源

redirect - 重定向对于 API 网关来说是有效的策略吗?

nginx - 具有自定义网络的 Docker 代理

soap - WildFly 8.2.0,使用反向代理的 JBossWS 生成不正确的 httpssoap :address

lua - 使用 FastCGI 运行 Lua 脚本