zoukankan      html  css  js  c++  java
  • django之允许外部机器访问

    开开启django时,使用0.0.0.0:xxxx,作为ip和端口例如:

    python3 manage.py runserver 0.0.0.0:9000

    然后在settings里修改ALLOWED_HOSTS = [],

    改为ALLOWED_HOSTS = ['*',],注意不要漏掉“,”。

    其他机器就可以通过这台机器的ip和端口号访问django了。

    例如:http://192.168.14.40:9000/index.html

    同时无论是Windows,还是linux,需要关闭防火墙才行。

    防火墙相关服务开启命令如下:
    CentOS Linux开启和关闭防火墙命令有两种,一种是临时的,重启即复原;另外一种是永久性的,重启不会复原。
    1) 临时生效,重启后复原
    开启: service iptables start
    关闭: service iptables stop
    2) 永久性生效,重启后不会复原
    开启: chkconfig iptables on
    关闭: chkconfig iptables off
    ---------------------
    windows 下直接关闭在控制面板关闭防火墙就可正常访问了
  • 相关阅读:
    3
    2
    1
    11
    12
    8888888888
    99999999999
    88888888888
    77777777
    10.23
  • 原文地址:https://www.cnblogs.com/it-tsz/p/10227109.html
Copyright © 2011-2022 走看看