Lighttpd 将 /main.py/ 附加到 URL

Lighttpd 将 /main.py/ 附加到 URL

我有一个使用在 lighttpd 上运行的 web.py 的 Web 服务器。

我的lighttpd.conf文件如下:

server.modules = ("mod_fastcgi", "mod_rewrite", "mod_compress", "mod_expire", "mod_redirect")
server.document-root = "/home/smiley/british_detail/code/"
server.name = "britishdetail.co.uk"

$HTTP["scheme"] == "http" {
  $HTTP["host"] =~ ".*" {
    url.redirect = (".*" => "https://%0$0")
  }
}

$SERVER["socket"] == ":443" {
  ssl.engine = "enable"
  ssl.pemfile = "/home/smiley/british_detail/certs/server.pem"
  ssl.ca-file = "/home/smiley/british_detail/certs/AddTrustExternalCARoot.crt"

  mimetype.assign = (
    ".html" => "text/html",
    ".css" => "text/css",
    ".jpg" => "image/jpeg",
    ".png" => "image/png",
    ".js"  => "text/javascript"
  )

  expire.url = (
    "/static" => "access plus 7 days"
  )    

  fastcgi.server = ( "/main.py" =>
  ((
    "socket" => "/tmp/fastcgi.socket",
    "bin-path" => "/home/smiley/british_detail/code/main.py",
    "max-procs" => 1
  ))
  )

  compress.cache-dir = "/tmp/lighttpdcompress/"
  compress.filetype = (
    "text/html",
    "text/css",
    "text/javascript"
  )

  url.rewrite-once = (
    "^/favicon.ico$" => "/static/assets/favicon.ico",
    "^/static/(.*)$" => "/static/$1",
    "^/(.*)$" => "/main.py/$1"
  )
}

我遇到的问题是,当请求从 http 请求重定向到 https 请求时,url 中会出现 /main.py/。例如: http://britishdetail.co.uk => https://britishdetail.co.uk/main.py/ 如果您想查看,该网站处于活动状态。

我该如何防止这种行为?

答案1

url.rewrite(-once)触发器url.redirect,因此如果您想重定向就不要重写;例如将您的主配置与块中的重定向(“仅 ssl”)分开$SERVER["socket"] == ":443"

相关内容