【问题标题】:How to access a site hosted on apache django over the internet如何通过互联网访问托管在 apache django 上的站点
【发布时间】:2017-08-10 17:09:54
【问题描述】:

我有一个使用 django 在 linux VM 上的 apache 服务器上设置的站点。这是conf文件:

<VirtualHost *:80>

    ServerAdmin webmaster@localhost
    DocumentRoot /home/sharan/myproject

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    Alias /static /home/sharan/myproject/proj_VivRx1/app_match/static
    <Directory /home/sharan/myproject/proj_VivRx1/app_match/static>
        Require all granted
    </Directory>

    <Directory /home/sharan/myproject/proj_VivRx1/proj_VivRx1>
        <Files wsgi.py>
            Require all granted
        </Files>
    </Directory>

    <Directory /home/sharan/myproject/proj_VivRx1/proj_VivRx1>
        Require all granted
    </Directory>

    <Directory /home/sharan/myproject/proj_VivRx1>
        Require all granted
    </Directory>

    <Directory /home/sharan/myproject/myprojectenv>
        Require all granted
    </Directory>

    WSGIDaemonProcess myproject python-path=/home/sharan/myproject/proj_VivRx1 python-home=/home/sharan/myproject/myprojectenv
    WSGIProcessGroup myproject
    WSGIScriptAlias / /home/sharan/myproject/proj_VivRx1/proj_VivRx1/wsgi.py

</VirtualHost>

我可以在本地机器浏览器中访问服务器IP地址,并且该站点运行良好。 如何通过 Internet 从另一台机器访问该站点进行测试? 我尝试使用 IP 地址,但“无法访问站点”

与建议的副本不同,因为我的问题是通过互联网访问,而不是从本地 IP 访问,而且我已经尝试了其中建议的答案

【问题讨论】:

  • 你在 Django 设置中设置了ALLOWED_HOSTS 吗?
  • 是的,我已将“*”添加到允许的主机。
  • 这个问题是通过本地IP访问的。我正在尝试通过 Internet 访问该站点。另外,我已经尝试了那里的答案。

标签: python django apache


【解决方案1】:

|我尝试使用 IP 地址,但“无法访问站点”

这让我觉得你在不同的层有问题——如果没有规则适用于你请求 URL,apache 将返回 404,如果你的 web 应用程序有问题,则返回 5XX(如果崩溃或无法访问) .

站点无法访问表明存在防火墙问题,或者当您想要引用外部地址时,您所引用的 IP 地址是内部地址。

【讨论】:

  • 谢谢。我如何确认它的防火墙问题?我在禁用防火墙后尝试过。如果它是一个引用问题,我怎样才能知道它是一个内部/外部地址
  • 假设防火墙完全关闭,并且使用netstat -tunlp | grep 80在服务器上打开端口80,您可以确定通过ping &lt;ip_address&gt;或ssh &lt;ip_address&gt;可以访问计算机。
  • 从远程机器ping到IP地址超时。
猜你喜欢
  • 2022-11-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-08-27
  • 2016-01-03
  • 1970-01-01
  • 2017-08-31
  • 1970-01-01
相关资源
最近更新 更多