如何在不中断FastCGI应用程序的情况下redirectURL?

(我认为这个问题是Lighttpd从www.domain.comredirect到domain.com的重复,但是没有得到足够的关注,而且太旧了)。

我试图通过lighttpd + FastCGI部署一个应用程序,并encryption所有的stream量。 如果我在URL中明确使用HTTPS,那么效果很好,但是尽快尝试从HTTPredirect到HTTPS,URL的应用程序脚本名称(在本例中为index.py)包含在URL中,因此不是https:/ /somedomain.com/bleh我得到https://somedomain.com/index.py/bleh ,这会触发未find错误。

我尝试过移动一些东西,但是我无法很好地完成redirect。 这里是我的lighttpd.conf的相关内容

$SERVER["socket"] == ":80" { $HTTP["host"] =~ "(.*)" { url.redirect = ( "^/(.*)" => "https://%1/$1" ) } } $SERVER["socket"] == ":443" { ssl.engine = "enable" ssl.pemfile = "certificate.pem" ssl.use-sslv2 = "disable" ssl.use-sslv3 = "disable" } fastcgi.server = ( "index.py" => (( "socket" => "/tmp/app.socket", "bin-path" => "index.py", "max-procs" => 1, "bin-environment" => ( "REAL_SCRIPT_NAME" => "" ), "check-local" => "disable" )) ) url.rewrite-once = ( "^/favicon.ico$" => "/static/assets/favicon.ico", "^/static/(.*)$" => "/static/$1", "^/(.*)$" => "/index.py/$1" ) 

重写之前发生重写。 在你的情况下,解决的办法是把fastcgi和重写在ssl套接字,因为你只是希望ssl无论如何。

请勿在/ tmp中产生套接字,请使用专用于此的目录,其中只有lighttpd可以创build文件。