Archive for 2010年9月7日

HTTP TRACE メソッドの無効化 on GF v3

GlassFish v3.0 の HTTP リスナーの設定はデフォルトで TRACE メソッドが有効になっています。

$ telnet localhost 8080
Trying ::1…
Connected to localhost.
Escape character is ‘^]’.
TRACE / HTTP/1.1
Host: localhost



HTTP/1.1 200 OK
Server: Oracle GlassFish Server 3.0.1
Content-Type: message/http
Content-Length: 35
Date: Tue, 07 Sep 2010 08:45:33 GMT


TRACE / HTTP/1.1
host: localhost

TRACE メソッドを無効化するためには、asadmin の set サブコマンドで trace-enabled オプションを true から false に変更してください。

$ asadmin set configs.config.server-config.network-config.protocols.protocol.http-listener-1.http.trace-enabled=false
configs.config.server-config.network-config.protocols.protocol.http-listener-1.http.trace-enabled=false

コマンド set は正常に実行されました。

設定変更後、再度アクセスすると無効になっている事を確認できます。

$ telnet localhost 8080
Trying ::1…
Connected to localhost.
Escape character is ‘^]’.
TRACE / HTTP/1.1
Host: localhost


HTTP/1.1 405 TRACE method is not allowed
Allow: POST, GET, DELETE, OPTIONS, PUT, HEAD

Content-Length: 0
Date: Tue, 07 Sep 2010 08:50:53 GMT

2010年9月7日 at 5:56 午後

X-Powered-By ヘッダの削除方法 on GF v3

ちょっとしたメモです。
GlassFish v3.0.x で X-Powered-By ヘッダを削除する方法を下記に示します。標準の設定で GlassFish にアクセスすると、下記のように “X-Powered-By” ヘッダが表示されます。

$ telnet localhost 8080
Trying ::1…
Connected to localhost.
Escape character is ‘^]’.
GET / HTTP/1.1
Host: localhost


HTTP/1.1 200 OK
X-Powered-By: Servlet/3.0
Server: Oracle GlassFish Server 3.0.1
Accept-Ranges: bytes
ETag: W/”5147-1282383202000″
Last-Modified: Sat, 21 Aug 2010 09:33:22 GMT
Content-Type: text/html
Content-Length: 5147
Date: Tue, 07 Sep 2010 08:10:51 GMT

これはデフォルトで作成される HTTP リスナーの設定において有効化されているためです。

$ ./asadmin get configs.config.server-config.network-config.protocols.protocol.http-listener-1.http.xpowered-by
configs.config.server-config.network-config.protocols.protocol.http-listener-1.http.xpowered-by=true

コマンド get は正常に実行されました。

これを無効化するためには、下記のように無効化(false)に設定してください。

$ ./asadmin set configs.config.server-config.network-config.protocols.protocol.http-listener-1.http.xpowered-by=false
configs.config.server-config.network-config.protocols.protocol.http-listener-1.http.xpowered-by=false

コマンド set は正常に実行されました。

設定変更後、再度アクセスすると”X-Powered-By” ヘッダが削除されている事を確認できます。

$ telnet localhost 8080
Trying ::1…
Connected to localhost.
Escape character is ‘^]’.
GET / HTTP/1.1
Host: localhost


HTTP/1.1 200 OK
Server: Oracle GlassFish Server 3.0.1
Accept-Ranges: bytes
ETag: W/”5147-1282383202000″
Last-Modified: Sat, 21 Aug 2010 09:33:22 GMT
Content-Type: text/html
Content-Length: 5147
Date: Tue, 07 Sep 2010 08:19:09 GMT

※ Server ヘッダは現時点では削除できませんが、もうすぐでできるようになるらしいです。
https://glassfish.dev.java.net/issues/show_bug.cgi?id=6900

追記:GlassFish v3.0.1では下記のサブコマンドを実施し変更できました。

$ ./asadmin create-jvm-options -Dproduct.name=”My Own Server”
1 オプションを作成しました
コマンド create-jvm-options は正常に実行されました。
$ ./asadmin restart-domain domain1
ドメインは正常に再起動されました
コマンド restart-domain は正常に実行されました。

ドメインを再起動した後、再度アクセスして確認してください。

$ telnet localhost 8080
Trying ::1…
Connected to localhost.
Escape character is ‘^]’.
GET / HTTP/1.1
Host: localhost


HTTP/1.1 200 OK
Server: My Own Server
Accept-Ranges: bytes
ETag: W/”5147-1282383202000″
Last-Modified: Sat, 21 Aug 2010 09:33:22 GMT
Content-Type: text/html
Content-Length: 5147
Date: Thu, 09 Sep 2010 01:58:41 GMT

2010年9月7日 at 5:27 午後


Java Champion & Evangelist

Translate

ご注意

このエントリは個人の見解であり、所属する会社の公式見解ではありません

カレンダー

2010年9月
 12345
6789101112
13141516171819
20212223242526
27282930  

カテゴリー

Twitter

  • RT @satyanadella: GitHub Copilot is the first at-scale developer tool, and today we're going further—bringing the power of Copilot past the… 8 hours ago
  • RT @seanjmullan: JDK 20 was released yesterday! Highlights of this release include further improvements that strengthen the default securit… 14 hours ago
  • RT @mkheck: Can’t get enough Spring content? Neither can I! That’s why I'm presenting "Build Better, Deploy Faster: Spring Boot + Spring C… 14 hours ago
  • RT @yuhattor: やばいのきました これからはエディターの外でも開発者の効率を爆上げします。まずはウェイトリスト登録! GitHub Copilot X👇 ●GPT4を採用 ●チャット/音声サポートでエディタでもChatGPTに似た体験 ●プルリクエストの文章自動生… 1 day ago
  • RT @github: GitHub Copilot is already helping developers code faster in their IDEs. But what’s next? Our answer is GitHub Copilot X. It’s… 1 day ago

clustermap

ブログ統計情報

  • 1,263,278 hits

RSSフィード

アーカイブ