2

我想在服务器级别而不是 web.xml 中禁用 JBoss wildfly 8.1 中的 TRACE/TRACK HTTP 方法。怎么做?

4

3 回答 3

1

感谢 Federico Sierra 的回复。我又试了一次,但默认情况下似乎没有禁用 TRACE。我得到 200 OK 状态码。见下文。

# curl -k -v -X TRACE https://localhost:8443 --user admin:Password@123
* About to connect() to localhost port 8443 (#0)
*   Trying ::1...
* Connection refused
*   Trying 127.0.0.1...
* connected
* Connected to localhost (127.0.0.1) port 8443 (#0)
* successfully set certificate verify locations:
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* SSLv3, TLS handshake, Client hello (1):
* SSLv3, TLS handshake, Server hello (2):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS handshake, Server key exchange (12):
* SSLv3, TLS handshake, Server finished (14):
* SSLv3, TLS handshake, Client key exchange (16):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSL connection using ECDHE-RSA-AES256-SHA384
* Server certificate:
*        subject: CN=scspr0021776001.gdl.englab.netapp.com
*        start date: 2015-02
*        expire date: 2016-02
*        common name: scspr0021776001.gdl.englab.netapp.com (does not match 'localhost')
*        issuer: CN=scsp
*        SSL certificate verify result: self signed certificate (18), continuing anyway.
* Server auth using Basic with user 'admin'
> TRACE / HTTP/1.1
> Authorization: Basic YWRtaW46UGFzc3dvcmRAMTIz
> User-Agent: curl/7.27.0
> Host: localhost:8443
> Accept: */*
>
< HTTP/1.1 200 OK
< Expires: 0
< Cache-Control: no-cache, no-store, must-revalidate
< X-Powered-By: Undertow/1
< Set-Cookie: JSESSIONID=j1Uh0ZpFl08-op1ak9dm6gr7.scspr0021776001; path=; HttpOnly
< Set-Cookie: JSESSIONIDSSO=jIoXps8-b3dByrQektBEZfOP; path=/
< Server: WildFly/8
< Pragma: no-cache
< Date: Wed, 18 Feb 2015 04:24:33 GMT
< Connection: keep-alive
< Content-Type: message/http
< Content-Length: 135
<
TRACE /index.html HTTP/1.1
Authorization: Basic YWRtaW46UGFzc3dvcmRAMTIz
Host: localhost:8443
User-Agent: curl/7.27.0
Accept: */*
* Connection #0 to host localhost left intact
* Closing connection #0
* SSLv3, TLS alert, Client hello (1):
于 2015-02-18T04:25:57.207 回答
0

默认情况下,出于安全原因,Wildfly TRACE 和 TRACK 方法被禁用。

您可以通过以下方式检查:

curl -v -X TRACE http://localhost:8080

* Rebuilt URL to: http://localhost:8080/
* Adding handle: conn: 0x1ddb0a0
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x1ddb0a0) send_pipe: 1, recv_pipe: 0
* About to connect() to localhost port 8080 (#0)
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 8080 (#0)
> TRACE / HTTP/1.1
> User-Agent: curl/7.33.0
> Host: localhost:8080
> Accept: */*
>
< HTTP/1.1 405 Method Not Allowed
< Connection: keep-alive
< X-Powered-By: Undertow/1
* Server WildFly/8 is not blacklisted
< Server: WildFly/8
< Content-Length: 83
< Content-Type: text/html
< Date: Tue, 17 Feb 2015 20:16:29 GMT
<
<html><head><title>Error</title></head><body>405 - Method Not Allowed</body></html>* Connection #0 to host localhost left intact
于 2015-02-17T20:24:37.903 回答
0

我设法禁用了 Wildfly 8.2 中的 HTTP TRACE(它应该适用于 Wildfly 8.1,但我尚未测试),并将以下内容添加到 webapp 中WEB-INF/undertow-handlers.conf

method[TRACE] -> response-code[value=405]

如果您有多个 web 应用程序,则必须将其添加到所有不需要响应 HTTP TRACE 请求的应用程序中。

于 2017-01-11T11:53:17.360 回答