如何配置lighttpd以服务于django静态文件?

如何配置lighttpd以服务于django静态文件?,django,gunicorn,lighttpd,Django,Gunicorn,Lighttpd,我有一个使用Django 2.0.5制作的web应用程序,安装在Debian 9的虚拟环境中,我在其中安装了Gunicorn和lighttpd。 我在/opt/djangoproject/mywebapp中安装了我的web应用程序。 我配置了lighttpd,将这些行添加到lighttpd.conf中 $HTTP["url"] !~ "/static" { proxy.server = ( "" => ( ( "host" => "192.168.1.15", "port" =&g

我有一个使用Django 2.0.5制作的web应用程序,安装在Debian 9的虚拟环境中,我在其中安装了Gunicorn和lighttpd。 我在/opt/djangoproject/mywebapp中安装了我的web应用程序。 我配置了lighttpd,将这些行添加到lighttpd.conf中

$HTTP["url"] !~ "/static" {
proxy.server = ( "" => ( (
"host" => "192.168.1.15", 
"port" => 8001
) ) )
}

alias.url = ( "/static/" => "/opt/djangoproject/mywebapp/mystaticfiles" )
问题是别名只在端口80上工作,而不是在8001上工作

更新:我忘了指定:

  • Gunicorn仅在192.168.1.15:8001上运行(使用此静态ip)
  • Lighttpd在端口80上运行(默认端口)
  • Debian安装在一台服务器上,我必须从连接在同一网络上的每台设备访问它

根据描述,听起来lighttpd在端口80上运行,gunicorn在端口8001上运行。如果gunicorn正在创建引用端口8001的内容,则客户端将直接连接到gunicorn(如果gunicorn正在侦听*:8001而不是127.0.0.1:8001),并将绕过lighttpd,因此lighttpd永远不会看到它。您应该更喜欢使用根相对链接(从url路径中的/开始)。

我知道问题出在哪里。配置是正确的,但我忘了在server.modules中包含“mod_proxy”。 添加模块(并重新启动lighttpd)后,一切正常。
我希望它对某人有用。

您好,我更新了我的问题:gunicorn运行在特定的IP(服务器的静态IP,192.168.1.15)上,我必须从连接到网络的每个设备访问它。Lighttpd在默认端口80上运行。我不明白如何配置lighttpd.conf来截获端口8001而不是端口80上的“/static/”请求。