Skip to end of metadata
Go to start of metadata

If you have an existing IIS instance and you want the Jiwa self hosted ReST API service to be running on the same machine, this article guides you how to setup IIS to act as a proxy to the Jiwa Self Hosted ReST API Service and rewrite the URL's so the service can be exposed on the same port (eg: 80 or 443) as your other sites.

In this example, I have a Windows Server 2019 server running RDS which exposes a web interface on port 443.  A DNS CNAME record for points to the Azure VM, and this serves up the RDS web interface.

We're using Cloudflare for DNS, so that record in the zone looks like this:

We want to setup the URL such that requests go to the same machine, but IIS forwards those to the locally running Jiwa ReST API service transparently to the user.

We have a wildcard SSL certificate for * which will be used for both sites, and we want the requests and responses to the Jiwa ReST API to be over SSL.

Step-by-step guide

  1. Create a CNAME record in the desired zone to act as the URL for your api requests - in our case we added a CNAME record for testapi to point to the same target as the RDS server :
  2. On the machine to run the service, configure the Jiwa Self Hosted ReST API service to use the URLBase of http://localhost:5492/ within the JiwaAPISelfHostedService.exe.config configuration file.  We cannot use port 80 or 443 as the IIS service is using that - we'll redirect requests to the api DNS name from port 443 to the Jiwa Self Hosted ReST API service shortly.
  3. Start the service and verify it is running by visiting the URL http://localhost:5492/ in a web browser - on the local machine.
  4. In IIS, create a new site by right clicking Sites and selecting Add Website... from the context menu
  5. Enter the Site name, Physical path (make a new empty folder anywhere), Type to be https, set the Host name and SSL Certificate:
  6. Download and Install the Web Platform Installer for IIS from
  7. When complete, Run the Web Platform Installer and search for Application Request Routing 3.0 and install it
  8. Now, when you select the Machine in IIS, a new option is present for Application Request Routing - double click to open
  9. Select Server Proxy Settings... from the right-hand pane
  10. Check Enable Proxy and leave all other settings as their defaults
  11. Click Apply from the right hand pane
  12. Click on the site in the IIS Sites folder - select the new option URL Rewrite
  13. Select Add Rule(s)... from the right hand pane
  14. In the Add Rule(s) dialog which appears, select the Reverse Proxy template and press OK
  15. In the Add Reverse Proxy Rules dialog which appears, enter the information as required - the local running Jiwa ReST API address (including port) should be entered into the Inbound rules server name.  Make sure the other checkboxes and fields are filled out as shown below.
  16. Visit the URL in a web browser (in this example and you should be presented with the Jiwa ReST API metadata page, server in SSL:

For reference, the web.config for the site testapi as configured in the example above looks like the following after following the above steps:

<?xml version="1.0" encoding="UTF-8"?>
                <rule name="ReverseProxyInboundRule1" stopProcessing="true">
                    <match url="(.*)" />
                    <action type="Rewrite" url="http://localhost:5492/{R:1}" />
                <rule name="ReverseProxyOutboundRule1" preCondition="ResponseIsHtml1">
                    <match filterByTags="A, Form, Img" pattern="^http(s)?://localhost:5492/(.*)" />
                    <action type="Rewrite" value="http{R:1}://{R:2}" />
                    <preCondition name="ResponseIsHtml1">
                        <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />