如何启用对python fcgi应用程序的外部访问?

时间:2011-07-21 19:17:05

标签: python lighttpd fastcgi

我有一个简单的网络应用,它显示一个简单的hello world。我可以通过网络浏览器(127.0.0.1:3000/test/hello)访问该应用程序,但无法使用运行应用程序的本地IP访问它,或使用我的外部IP(我已经在我的路由器上正确转发了端口) )。

server.modules += ( "mod_fastcgi" )

server.document-root = "/Users/me/test"
server.port = 3000
server.bind = "127.0.0.1"

fastcgi.debug = 1

fastcgi.server = (
    "test" =>
    (
        "python-fcgi" =>
        (
         "socket" => "/tmp/fastcgi.python.socket",
         "bin-path" => "/Users/me/hello.py",
         "check-local" => "disable",
         "max-procs" => 1,
        )
    ))

如何使用外部IP访问网络应用程序?

3 个答案:

答案 0 :(得分:1)

server.bind设置为服务器的本地网络IP而不是localhost 127.0.0.1。还要检查网络上的主机之间是否未阻止端口3000。

通过绑定到localhost,您将被绑定到计算机的环回接口,这意味着lighttpd甚至根本不在网络上监听。

或者,要接受请求而不管它们如何定向到服务器,请绑定到启用所有接口的0.0.0.0

答案 1 :(得分:1)

不要绑定到特定的IP地址,绑定到0.0.0.0。这样您就可以在127.0.0.1以及任何外部IP地址上访问它。

答案 2 :(得分:0)

您的服务器在loopback界面上绑定/侦听。将server.bind行更改为绑定/侦听计算机的IP地址。

相关问题