LoginSignup
5
6

More than 5 years have passed since last update.

telnet を使った VirtualHost の動作確認

Last updated at Posted at 2016-01-04

DNS書き換え前に VirtualHost の動作を確認する方法

DNS 書き換え前でも、hosts ファイルを書き換えてブラウザでアクセスすればいいのですが、もっと簡単に確認する方法です。

名前ベースの VirtualHost は、HTTP の Host ヘッダの文字列を見てVirtualHost を判定します。

VirtualHost側設定

たとえば、以下のような VirtualHost 設定を行ったとします。

<VirtualHost 192.168.1.1:80>
ServerName "www.example.com"
:
</VirtualHost>

telnetでアクセス

192.168.1.1 の 80番ポートに telnet で接続します。

% telnet 192.168.1.1 80

リクエスト

GET でコンテンツを取得します。この時 Host ヘッダを付与します。
(空行が必要なので、\n を記載しておきます)

GET / HTTP/1.0\n
Host: www.example.com\n\n

VirtualHost が正しく動作すれば、VirtualHost に定義されたコンテンツが表示されます。
もし設定が正しくない場合は、defaultのコンテンツが表示されます。

5
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
6