关于0.0.0.0这个ip的疑问

用bottle的一个项目中,uwsgi作为bottle跟nignx通信协议,取代fastcgi。

uwsig配置脚本如下:

<uwsgi>
  <socket>0.0.0:9999</socket>
  <listen>128</listen>
  <master>true</master>
  <pidfile>/yourpythonprojectpathr/log/uwsgi.pid</pidfile>
  <processes>9</processes>
    <chdir>/yourpythonprojectpathr/</chdir>
  <pythonpath>..</pythonpath>
  <module>application</module>
  <profiler>true</profiler>
  <memory-report>true</memory-report>
  <enable-threads>true</enable-threads>
  <logdate>true</logdate>
  <limit-as>512</limit-as>
  <daemonize>/yourpythonprojectpathr/log/uwsgi.log</daemonize>
</uwsgi>

nignx放置前面,做反向代理。

server {
            listen       80;
            server_name  server_name;
            merge_slashes off;

            location = /favicon.ico  {
                empty_gif;
                access_log off;
            }
            location /cross_origin.htm {
                           expires 30d;
            }

            location / {
                include uwsgi_params;
                uwsgi_pass 127.0.0.1:9999;
            }

    }

可以看出,所有的请求都会127.0.0.1:9999直接让bottle处理。问题来了。uwsgi里的<socket>0.0.0:9999</socket>为什么Ip不是127.0.0.1

网上搜寻了好半天,还是觉得http://www.linuxask.com/questions/what-is-the-difference-between-ip-address-0-0-0-0-and-127-0-0-1解释的让我明白

In fact, this special IP means "all the IP addresses on the local machine". So if you have seen a service listening on 0.0.0.0, it means you can connect to the service using any IP addresses of the machine.

原文地址:https://www.cnblogs.com/liuyongjians/p/3296899.html