2017-09-17 63 views
0

我的網站使用IP但不與域一起使用。ip works,domain不,curl -v發現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'(與我的地方123.123.123.123的IP),一切工作正常,我也得到:

* 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 

我在瀏覽器中得到相同的行爲。你好世界頁面顯示與ip但不是與域。

我可能會錯過什麼?

捲曲IP時返回的hello世界內容恰好就是我所期望的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> 

我已經爲大量類似的問題提出了stackoverflow,但沒有發現我似乎是完全相同的問題。

任何想法?提前致謝。

(PS:我真的不確定我添加的標籤,因爲我真的不知道問題出在哪裏)。

+0

內部的「 IP主機「和」域主機「可能由該http服務器內的不同虛擬主機處理。我們需要查看主機配置和設置的詳細信息才能提供幫助。 – arkascha

+0

我的/etc/host.conf如下所示: #「訂單」行只用於舊版本的C庫。 訂單主機,綁定 多 –

+0

對不起,但請不要在評論中發佈額外的信息,這是不可能讀取的。您的問題下方有一個「編輯」鏈接。 _使用它_... – arkascha

回答

0

你必須讓捲曲使用-L 所以

curl -v -L 'example.com' 
+0

如果問題出現,您是否會在服務器的響應中看到重定向標頭? – arkascha

+0

我剛剛從使用我自己的域名得到完全相同的結果,它給我的結果是OP有問題。使用-L會按預期給出頁面。 –

+0

所以這是一個「經驗答案」,因爲你根本沒有回答我的問題;-) – arkascha

0

第一件事嘗試檢查域正確配置和解決到您的實例/服務器的IP遵循任何重定向:

dig example.com +short 

這應該給你的服務器的IP,如果你不使用CDN的東西就像CloudFlare

如果正在檢查是否具有正確配置爲您的域接收請求的Web服務器,如果你使用Nginx的,你可以有這樣的事情:

server { 
    listen  80; 
    server_name *.example.com; 
    ... 
} 

通知的server_name *.example.com