大网数据广告活动
服务器运维问答

Cross platform reverse proxy with lighttpd

· 52CE 我爱测

I have a website www.somewebsite.com domain hosted on lighttpd 1.4 server configured with server.port = 8080 that is on a device (A) with local IP 192.168.1.26 and I want to get to use a reverse proxy in order to access another s…

问题原文

原帖链接 · AndreaF · CC BY-SA 4.0

I have a website www.somewebsite.com domain hosted on lighttpd 1.4 server configured with server.port = 8080 that is on a device (A) with local IP 192.168.1.26 and I want to get to use a reverse proxy in order to access another server that runs on a different device (B) at 192.168.1.30:80/myappin order to be accessed as

somewebsite.com/myapp

In device (A) server config I have enabled mod_proxy and I have tried to add

$HTTP["url"] =~ "^.*myapp" {
    proxy.server  = ( "" => 
        (( "(www.)?somewebsite.com" => "192.168.1.30", "port" => 80 ))
    )
}

but I get internal server error page when I try to access somewebsite.com/myapp

I have tried also

$HTTP["url"] =~ "(^/myapp/)" {   
  proxy.server  = ( "" => ("" => ( "(www.)?somewebsite.com" => "127.0.0.1", "port" => 8080 ))) 
}

$SERVER["socket"] == ":81" {   
  url.rewrite-once = ( "^/myapp/(.*)$" => "/$1" )   
  proxy.server  = ( "" => ( "" => ( "(www.)?somewebsite.com" => "192.168.1.30", "port" => 80 ))) 
}

but the result is even worse and server crashes completely

已采纳解答

原帖链接 · kab00m · CC BY-SA 4.0

proxy.server do not take host as an argument, and "host" is a keyword, not a place to put your host here.

Try this:

$HTTP["host"] =~ "(www.)?somewebsite.com" {
 $HTTP["url"] =~ "^/myapp/" {
  url.rewrite-once = ("^/myapp/(.*)" => "/newapp/$1") # If you need to rewrite context.
  proxy.server  =  ( "" => ( "" => ("host" => "192.168.1.30", "port" => 80 )))
  }
}

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2020-10-31)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。