nginx:尝试通过域名从服务器本身进行curl会导致超时

vmdwslir  于 2023-08-03  发布在  Nginx
关注(0)|答案(1)|浏览(159)

所以我sub.domain.com通过nginx作为vhost在我的OpenSUSE Tumbleweed服务器上托管了一个网站www.example.com。从互联网访问工作正常,但当我SSH进入服务器并尝试curl https://sub.domain.com时,它导致超时。这是预期的行为吗?如果是这样,那么有没有一种方法可以配置nginx通过URL为自己服务?
这不是防火墙问题,我可以很好地curl google.com
感谢您的任何想法:)高兴地张贴配置文件,以及如果需要的话,但我已经尝试注解了所有,但一个非常准的配置,它仍然没有工作。

  • 通过SSH连接到托管sub.domain.com的服务器
  • curl https://sub.domain.com
  • 期望值:成功 curl 结果
  • 结果: curl 超时

Zac Anger建议的故障排除:
dig sub.domain.com +short =>正确的IP
curl -v https://sub.domain.com =>

*   Trying 11.22.33.123:443...
* connect to 11.22.33.123 port 443 failed: Connection timed out
* Failed to connect to sub.domain.com port 443 after 130849 ms: Couldn't connect to server

字符串
curl -v 11.22.33.123 -H 'Host: sub.domain.com' =>

*   Trying 11.22.33.123:80...
* connect to 11.22.33.123 port 80 failed: Connection timed out
* Failed to connect to 11.22.33.123 port 80 after 129671 ms: Couldn't connect to server
* Closing connection 0
curl: (28) Failed to connect to 11.22.33.123 port 80 after 129671 ms: Couldn't connect to server


curl localhost -H 'Host: sub.domain.com' =>

<html>
<head><title>301 Moved Permanently</title></head>
<body>
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx</center>
</body>
</html>


curl https://localhost -H 'Host: sub.domain.com' =>

curl: (60) SSL: no alternative certificate subject name matches target host name 'localhost'
More details here: https://curl.se/docs/sslcerts.html

curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.

olhwl3o2

olhwl3o21#

我想我通过将域名添加到/etc/hosts来解决这个问题:
它现在有以下127.0.0.1条目:
127.0.0.1 sub.domain.com localhost.localdomain localhost
再次感谢Zac Anger帮助我解决这个问题,非常感谢!

相关问题