概要
Webページのアクセス先の内容を確認するために、ヘッダを確認したいという事がある。
その時は、curlコマンドで確認してみよう。
実行コマンド
curl -I urlまたはfqdn
実行結果
HTTP/1.1 404 Not Found
Date: Sat, 09 Sep 2023 14:37:06 GMT
Server: WSGIServer/0.2 CPython/3.11.0
Content-Type: text/html; charset=utf-8
X-Frame-Options: DENY
X-Content-Type-Options: nosniff
Referrer-Policy: same-origin
Cross-Origin-Opener-Policy: same-origin
Set-Cookie: xascszzzzzzzzzzzzzzz
そして、ここでいうServer
の欄が、返答している者である。
サーバによっては、nginxだったりが返答している事もある。
[user@server~]$ curl -Ik https://略
HTTP/1.1 200 OK
Server: nginx/1.22.1
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
X-Powered-By: PHP/8.1.2
Cache-Control: no-cache, private
略
リダイレクトになっているかは、Location
で確認できる。
以下のように、Locationがhttpsでそのままつけられて表示されているときは、
- httpsをつけて実行
- もしくは
curl -L
でリダイレクト先を確認できる。
リダイレクト先が表示されえない
[user@server~]$ curl -Ik https://sample~~
HTTP/1.0 302 Moved Temporarity
Location: https://sample~~
Server: BIGIP
Connection: keep-alive
Content-Length: 0
curl -I https://~~~
もしくは
curl -IL htttp://~~
実行結果
[user@server~]$ curl -Ik https://略
HTTP/1.1 200 OK
Server: nginx/1.22.1
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
X-Powered-By: PHP/8.1.2
Cache-Control: no-cache, private
略