LinuxのcurlコマンドでWebページのヘッダ情報を確認する方法

LinuxコンソールでWebページ(Webサイト)のヘッダ情報を確認したいと思う場合がある。

curlコマンドを使えば、ヘッダ情報は簡単に確認できる。

【書式】
curl -I Webページ(Webサイト)のURL

《参考》CentOS 6.6のmanコマンドで確認できるcurlのマニュアル(一部抜粋)
Curl Manual
-I/--head
(HTTP/FTP/FILE) Fetch the HTTP-header only! HTTP-servers feature the command HEAD which this uses to get nothing but the header of a doc-
ument. When used on a FTP or FILE file, curl displays the file size and last modification time only.

《コマンド実行例》
[root@test ~]# curl -I http://httpd.apache.org/
HTTP/1.1 200 OK
Date: Sat, 07 Feb 2015 14:51:16 GMT
Server: Apache/2.4.7 (Ubuntu)
Last-Modified: Fri, 06 Feb 2015 15:46:23 GMT
ETag: "1988-50e6d529d32c1"
Accept-Ranges: bytes
Content-Length: 6536
Vary: Accept-Encoding
Content-Type: text/html

Apacheの公式サイトが使用しているサーバソフトウェアは、同サイトで開発しているApacheのようだった。
Apacheのバージョン番号の隣にUbuntuの記載があるので、OSはUbuntuを使用しているのかもしれない。

[root@test ~]# curl -I http://www.centos.org/
HTTP/1.1 200 OK
Server: nginx/1.0.15
Date: Sat, 07 Feb 2015 14:52:33 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
Last-Modified: Mon, 19 Jan 2015 16:33:04 GMT
ETag: "20621-407d-50d03e05ff000"
Accept-Ranges: bytes
Content-Length: 16509

→CentOSの公式サイトが使用しているサーバソフトウェアは、nginxのようだった。

[root@test ~]# curl -I http://php.net/
HTTP/1.1 200 OK
Server: nginx/1.6.2
Date: Sat, 07 Feb 2015 15:25:50 GMT
Content-Type: text/html; charset=utf-8
Connection: keep-alive
X-Powered-By: PHP/5.6.5-1
Last-Modified: Sat, 07 Feb 2015 15:20:10 GMT
Content-language: en
X-Frame-Options: SAMEORIGIN
Set-Cookie: COUNTRY=NA%2C240f%3Aa8%3A3bc6%3A1%3A20c%3A29ff%3Afeb7%3A8c6a; expires=Sat, 14-Feb-2015 15:25:50 GMT; Max-Age=604800; path=/; domain=.php.net
Set-Cookie: LAST_NEWS=1423322750; expires=Sun, 07-Feb-2016 15:25:50 GMT; Max-Age=31536000; path=/; domain=.php.net
Link: <http://php.net/index>; rel=shorturl

→PHPの公式サイトが使用しているサーバソフトウェアは、nginxのようだった。

[root@test ~]# curl -I http://www.postgresql.org/
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Server: lighttpd/1.4.31
Date: Sat, 07 Feb 2015 14:50:16 GMT
X-Varnish: 1080776999 1080776655
Age: 58
Via: 1.1 varnish
Connection: keep-alive

→PostgreSQLの公式サイトが使用しているサーバソフトウェアは、lighttpdのようだった。

[root@test ~]# curl -I http://www.postgresql.jp/
HTTP/1.1 200 OK
Date: Sat, 07 Feb 2015 14:50:29 GMT
Server: Zope/(Zope 2.9.9-final, python 2.4.3, linux2) ZServer/1.1 Plone/Unknown
Content-Length: 2980
Accept-Ranges: none
Last-Modified: Tue, 04 Dec 2012 11:28:50 GMT
Content-Type: text/html

→PostgreSQLの日本語の公式サイトが使用しているサーバソフトウェアは、Zopeのようだった。

[root@test ~]# curl -I http://www.microsoft.com/
HTTP/1.1 200 OK
Cache-Control: no-cache
Content-Length: 1020
Content-Type: text/html
Last-Modified: Mon, 16 Mar 2009 20:35:26 GMT
Accept-Ranges: bytes
ETag: "67991fbd76a6c91:0"
Server: Microsoft-IIS/8.0
X-Powered-By: ASP.NET
Date: Sat, 07 Feb 2015 15:30:13 GMT
Connection: keep-alive
X-CCC: JP
X-CID: 2

→マイクロソフトの公式サイトが使用しているサーバソフトウェアは、自社製品のMicrosoft-IISのようだった。

[root@test ~]# curl -I http://www.apple.com/
HTTP/1.1 200 OK
Content-Type: text/html; charset=UTF-8
Cache-Control: max-age=246
Expires: Sat, 07 Feb 2015 14:59:09 GMT
Date: Sat, 07 Feb 2015 14:55:03 GMT
Connection: keep-alive
Server: Apache

→Appleの公式サイトが使用しているサーバソフトウェアは、Apacheのようだった。
(Apacheのバージョン番号は隠蔽されている。)

[root@test ~]# curl -I http://www.yahoo.co.jp/
HTTP/1.1 200 OK
Server: nginx
Date: Sat, 07 Feb 2015 15:32:53 GMT
Content-Type: text/html; charset=UTF-8
Connection: close
P3P: policyref="http://privacy.yahoo.co.jp/w3c/p3p_jp.xml", CP="CAO DSP COR CUR ADM DEV TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi PUBi IND PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE GOV"
Cache-Control: private, no-cache, no-store, must-revalidate
Expires: -1
Pragma: no-cache
X-XRDS-Location: https://open.login.yahooapis.jp/openid20/www.yahoo.co.jp/xrds
Vary: Accept-Encoding
X-Frame-Options: SAMEORIGIN

→Appleの公式サイトが使用しているサーバソフトウェアは、Apacheのようだった。

Webサービスのソフトウェアと言えば、ApacheとIISぐらいしか知らなかったが、今日、curlコマンドを実行して、私が普段見ているサイトを確認すると、nginx、lighttpd、Zopeなど、ApacheやIIS以外のソフトウェアが使われている例が多くて驚いた。

2015年2月7日現在、nginxは大手サイト「YAHOO!JAPAN」で採用されているようなので、今後、もっと注目されるかもしれない。

前へ

PostgreSQL 8.4のpg_hba.confの設定変更を反映するには、サービスのリロードでOK

次へ

Mister Donut(ミスタードーナツ)の麻婆豆腐麺が辛い!