简体   繁体   English

无法通过域URL访问Nginx网站

[英]Nginx site cannot be accessed through domain URL

The problem: 问题:

I have set up a (Docker) Django-Gunicorn-Nginx site on my home network. 我在家庭网络上建立了一个(Docker)Django-Gunicorn-Nginx站点。 It works on the local network but I cannot access it through my domain. 它可以在本地网络上运行,但是我无法通过我的域访问它。

The setup: 设置:

  • Registered a domain in namecheap.com. 在namecheap.com中注册了一个域。
  • Set up a dynamic DNS to update my public IP with the namecheap domain. 设置动态DNS以使用namecheap域更新我的公共IP。
  • Set up the website on a computer in my home network and give it a static IP. 在我的家庭网络中的计算机上设置网站,并为其提供静态IP。
  • Enable port forwarding from public 80 to LAN 80. 启用从公共80到LAN 80的端口转发。

The tests: 测试:

  • I have enabled port forwarding on the port 22 and I have been able to connect through SSH to the computer serving the website with ssh user@domain and it worked well -> domain/ddns ok . 我已经在端口22上启用了端口转发,并且已经能够通过SSH通过ssh user@domain连接到服务该网站的计算机,并且运行良好-> domain/ddns ok

  • I have accessed to the website from another computer connected on the same LAN by using the full static IP to the computer serving the website and it worked well -> website/server ok . 我已经通过使用连接到该网站的计算机的完整静态IP从连接在同一LAN上的另一台计算机访问该网站,并且该网站运行良好-> website/server ok

  • I have called my ISP to check if everything is set up correctly and if I am allowed to serve a website form my network and apparently there are no issues -> router/network ok . 我已经致电ISP来检查是否一切设置正确,是否可以通过我的网络为网站提供服务,显然没有问题-> router/network ok

The clue: 线索:

When I try to access the site from outside my home network, through the domain or my full public IP, I get an ERR_EMPTY_RESPONSE. 当我尝试从我的家庭网络外部,通过域或我的完整公共IP访问该站点时,会收到ERR_EMPTY_RESPONSE。

When I try to access the site from my home network, through the domain or with the full public IP (not through the LAN IP which actually works), I get redirected to the page 192.168.0.1/intercept.html which contains a message from my ISP saying that I do not have connection to the internet (which I actually have): 当我尝试通过域或完整的公共IP(而不是通过实际起作用的LAN IP)从家庭网络访问站点时,将重定向到页面192.168.0.1/intercept.html,其中包含来自我的ISP说我没有连接到互联网(实际上是):

在此处输入图片说明

So, at this point I am a bit lost. 所以,在这一点上我有点迷茫。 I'd like to get ideas on what is the best way to troubleshot this situation. 我想了解解决这种情况的最佳方法是什么。

As @ben5556 suggested, I tried port 8000 and it worked :) So my ISP is probably blocking port 80. 正如@ ben5556所建议的那样,我尝试使用端口8000并起作用:)因此,我的ISP可能阻塞了端口80。

First I tried port 8080 but while enabling the port forwarding on the router configuration page, it showed a warning stating that this port is reserved for other stuff so I tried with port 8000 instead. 首先,我尝试使用端口8080,但是在路由器配置页面上启用端口转发时,它显示警告,指出该端口是为其他端口保留的,因此我尝试使用端口8000。

This is annoying since I called my ISP and they said that there should be no problem in using port 80. Moreover, there is no warning at all when enabling port forwarding on port 80. 自从我打电话给ISP以来,这很烦人,他们说使用端口80应该没有问题。此外,在端口80上启用端口转发时完全没有警告。

UPDATE 更新

Serving the web on public port 8000 makes no sense since browsers default to port 80, so the final solution has been to enable port forwarding from public 80 to LAN 8000. Apparently only LAN port 80 is blocked so this solution works nicely. 由于浏览器默认使用端口80,因此在公共端口8000上为网络提供服务没有任何意义,因此最终的解决方案是启用从公共80到LAN 8000的端口转发。显然,只有LAN端口80被阻止,因此该解决方案可以很好地工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM