Saturday, August 2, 2014

Configuring WSO2 APIManager with Apache HTTP server for reverse proxy

Applies to : AM -  1.8.0

APIManager which has two web apps deployed by default which are api_publisher and api_store. When user needs to route the requests through a proxy server for publisher and store, he can do that by editing  site.json file which is available in AM_HOME/repository/deployment/server/jaggeryapps/store(/publisher)/site/conf folder.

Apache HTTP server
  • Download and install HTTP server
  • Check the default installation works fine for HTTP.
    • Try like "http://localhost" you will see the default index page.
  • To set SSL settings, edit the default http_ssl config file with the following settings. User has to create a new ssl cert/key for ssl communication. 
<VirtualHost _default_:443>
SSLEngine on
SSLCertificateFile /Users/ratha/WSO2/apachehttp/server.crt
SSLCertificateKeyFile /Users/ratha/WSO2/apachehttp/server.key

ProxyPreserveHost On
SSLProxyEngine on

# Proxy path which user wants to map with actual backend
ProxyPass /publicstore https://localhost:9443/store/
ProxyPassReverse /publicstore https://localhost:9443/store/
ProxyPassReverseCookiePath /store /publicstore

ProxyPass /publicpublisher https://localhost:9443/publisher/
ProxyPassReverse /publicpublisher  https://localhost:9443/publisher/
ProxyPassReverseCookiePath /publisher /publicpublisher

</VirtualHost>


  • After editing the ssl configuration restart the http server. Try accessing "https://localhost", if settings are fine, user should be able to see the default index page.
site. json configuration

Edit the context and request-url parameters.
context- The url context
request_url- The original request url which hits the proxy server.

"context" : "/publicstore ",
"request_url":"https://localhost/publicstore ",

Now access the store page(/publisher ) using 'https://localhost/publicstore' and  the request  will be routed internally to 'https://localhost/store'

3 comments:

  1. How we can proxy RestFul web services (Spring MVC) in WSO2 API Manager? Could you please provide steps / links etc? Thanks, Deepak

    ReplyDelete
  2. For your service you will have service endpoint. Use that as your production/sandbox endpoint at Publisher portal.

    ReplyDelete
  3. how do i make a reverse proxy of two carbon instance with different port. any idea?

    https://localhost:9443/carbon
    https://localhost:9446/carbon

    ReplyDelete