我的网站使用ip而不是域名。
当我curl -v 'example.com'
(以我的域名代替示例)时,我得到:
* Rebuilt URL to: example.com/
* Trying 123.123.123.123...
* Connected to example.com (123.123.123.123) port 80 (#0)
> GET / HTTP/1.1
> Host: example.com
> User-Agent: curl/7.47.0
> Accept: */*
>
* Empty reply from server
* Connection #0 to host example.com left intact
curl: (52) Empty reply from server
然而,当我curl -v '123.123.123.123'
(用我的IP取代123.123.123.123)时,一切正常,我得到了:
* Rebuilt URL to: 123.123.123.123/
* Trying 123.123.123.123...
* Connected to 123.123.123.123 (123.123.123.123) port 80 (#0)
> GET / HTTP/1.1
> Host: 123.123.123.123
> User-Agent: curl/7.47.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Server: nginx
< Date: Sun, 17 Sep 2017 06:45:56 GMT
< Content-Type: text/html; charset=UTF-8
< Transfer-Encoding: chunked
< Connection: keep-alive
< Vary: Accept-Encoding
<
<!DOCTYPE html>
<html lang="en">
<head>
<title>Hello World Test Page</title>
</head>
<body>
<h1>Hello World</h1>
<p>Test page.</p>
</body>
</html>
* Connection #0 to host 123.123.123.123 left intact
我在浏览器中得到了相同的行为。 Hello世界页面显示ip但不显示域名。
我可能错过什么?
卷曲ip时返回的hello world内容正是我所期望的index.php
文件的内容。
我在48小时前设置了DNS,因此不应该出现问题(并且在域上查询时,似乎没有看到curl返回正确的ip。)
我尝试使用以下内容添加默认的.htaccess
文件,但这并没有改变结果。
# basic compression
<IfModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file \.(html?|txt|css|js)$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</IfModule>
# Protect files and directories
<FilesMatch "(\.(engine|inc|info|install|module|profile|po|sh|.*sql|theme|tpl(\.php)? |xtmpl)|code-style\.pl|Entries.*|Repository|Root|Tag|Template)$">
Order allow,deny
</FilesMatch>
# Don’t show directory listings
Options -Indexes
# Basic rewrite rules, stop unneeded PERL bot, block subversion directories
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*/)?\.svn/ - [F,L]
ErrorDocument 403 "Access Forbidden"
RewriteCond %{HTTP_USER_AGENT} libwww-perl.*
RewriteRule .* – [F,L]
</IfModule>
我已经刮掉了大量类似问题的堆栈溢出,但我发现的似乎都不是完全相同的问题。
有什么想法吗?提前谢谢。
(PS:我真的不确定我添加的标签,因为我真的不知道问题出在哪里)。
答案 0 :(得分:0)
您必须使用-L
让curl遵循任何重定向
所以
curl -v -L 'example.com'
答案 1 :(得分:0)
首先尝试检查域是否已正确配置并解析为您的实例/服务器的IP:
dig example.com +short
如果您没有使用<Play>
如果有效,请检查您是否正确配置了Web服务器以接收来自您域的请求,如果您使用的是Nginx,则可以使用以下内容:
server {
listen 80;
server_name *.example.com;
...
}
注意server_name *.example.com