Saturday, April 9, 2016

Customize HTTP Server Response Header in WSO2 API Manager / WSO2 ESB


You may know that in the response header from WSO2 ESB invocations or WSO2 API Manager invocations, You are getting "Server" header as bellow.

HTTP/1.1 200 OK
Access-Control-Allow-Headers: authorization,Access-Control-Allow-Origin,Content-Type,SOAPAction
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST,GET,DELETE,PUT,HEAD
Content-Type: application/json
Access-Control-Allow-Credentials: true
Date: Sat, 09 Apr 2016 20:02:58 GMT
Server: WSO2-PassThrough-HTTP
Transfer-Encoding: chunked
Connection: Keep-Alive

{
  "origin": "50.185.34.119"
}


You can see that Server Header Contains WSO2 as bellow.

Server: WSO2-PassThrough-HTTP

Sometimes there are situations like It needs to customize this header.

Eg: If we need to customize this as bellow.

Server: PassThrough-HTTP

What we need to do is , 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=PassThrough-HTTP

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

HTTP/1.1 200 OK
Access-Control-Allow-Headers: authorization,Access-Control-Allow-Origin,Content-Type,SOAPAction
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST,GET,DELETE,PUT,HEAD
Content-Type: application/json
Access-Control-Allow-Credentials: true
Date: Sat, 09 Apr 2016 20:11:47 GMT
Server: PassThrough-HTTP
Transfer-Encoding: chunked
Connection: Keep-Alive

{
  "origin": "50.185.34.119"
}

1 comment:

  1. Your blog has given me that thing which I never expect to get from all over the websites. Its very easy to understand and very helpful. Nice post guys!

    Web Developer Tips

    ReplyDelete