Sunday, February 19, 2017

Customize the response header "Server: WSO2-PassThrough-HTTP" in WSO2

In some scenarios you want to customize the Server header which is going out from the ESB. By default inside ESB, it is setting  the Server header to WSO2-PassThrough-HTTP [1].

[1]

[2017-02-17 13:18:14,920] DEBUG - wire << "HTTP/1.1 200 OK[\r][\n]"
[2017-02-17 13:18:14,920] DEBUG - wire << "RevokedAccessToken: wV4dUQ4HGHiNbsb2zIFKmMftLqEa[\r][\n]"
[2017-02-17 13:18:14,920] DEBUG - wire << "AuthorizedUser: admin[\r][\n]"
[2017-02-17 13:18:14,920] DEBUG - wire << "Content-Type: text/html[\r][\n]"
[2017-02-17 13:18:14,920] DEBUG - wire << "Pragma: no-cache[\r][\n]"
[2017-02-17 13:18:14,920] DEBUG - wire << "Cache-Control: no-store[\r][\n]"
[2017-02-17 13:18:14,920] DEBUG - wire << "Date: Fri, 17 Feb 2017 07:48:14 GMT[\r][\n]"
[2017-02-17 13:18:14,921] DEBUG - wire << "Server: WSO2-PassThrough-HTTP[\r][\n]"
[2017-02-17 13:18:14,921] DEBUG - wire << "Transfer-Encoding: chunked[\r][\n]"
[2017-02-17 13:18:14,921] DEBUG - wire << "Connection: Keep-Alive[\r][\n]"
[2017-02-17 13:18:14,921] DEBUG - wire << "[\r][\n]"
[2017-02-17 13:18:14,923] DEBUG - wire << "0[\r][\n]"
[2017-02-17 13:18:14,923] DEBUG - wire << "[\r][\n]"

Lets assume that need to customize the server header from "WSO2-PassThrough-HTTP" to "MyServerHeader" as bellow which coming with the response.

Server: MyServerHeader

Then you need to add the http.origin-server to passthru-http.properties file located in ESB_HOME/repository/conf/ directory with customized value as bellow.


http.origin-server=MyServerHeader

Once you restart the server, the response will be changed as bellow with the changed server header.


[2017-02-17 13:34:14,867] DEBUG - wire << "HTTP/1.1 200 OK[\r][\n]"
[2017-02-17 13:34:14,867] DEBUG - wire << "Access-Control-Allow-Headers: authorization,Access-Control-Allow-Origin,Content-Type[\r][\n]"
[2017-02-17 13:34:14,867] DEBUG - wire << "Via: 1.1 vegur[\r][\n]"
[2017-02-17 13:34:14,867] DEBUG - wire << "Content-Type: text/plain; charset=utf-8[\r][\n]"
[2017-02-17 13:34:14,867] DEBUG - wire << "Date: Fri, 17 Feb 2017 08:04:14 GMT[\r][\n]"
[2017-02-17 13:34:14,867] DEBUG - wire << "Server: MyServerHeader[\r][\n]"
[2017-02-17 13:34:14,867] DEBUG - wire << "Transfer-Encoding: chunked[\r][\n]"
[2017-02-17 13:34:14,868] DEBUG - wire << "Connection: Keep-Alive[\r][\n]"
[2017-02-17 13:34:14,868] DEBUG - wire << "[\r][\n]"
[2017-02-17 13:34:14,869] DEBUG - wire << "a[\r][\n]"
[2017-02-17 13:34:14,870] DEBUG - wire << "responseee[\r][\n]"
[2017-02-17 13:34:14,870] DEBUG - wire << "0[\r][\n]"
[2017-02-17 13:34:14,870] DEBUG - wire << "[\r][\n]"

Thanks.

No comments:

Post a Comment

Blogger Widgets