Setting up IIS as Reverse Proxy for QPR UI

From Mea Wiki
Revision as of 06:37, 3 November 2017 by TeeHiet (talk | contribs)
Jump to navigation Jump to search

Follow these instructions to route QPR MobileDashboard HTTP traffic though IIS. It has the following advantages:

  • access QPR MobileDashboard using IIS port (usually 80) instead of QPR MobileDashboard port (usually 8080).
  • QPR MobileDashboard can use HTTPS connection that is configured in IIS, and thus there is not need to configure HTTPS in GlassFish.
  • External presentation objects and embedded QPR Portal works better as the browser considers they are from the same site because same origin policy won't cause restrictions (more information: https://en.wikipedia.org/wiki/Same-origin_policy)

Instructions:

  1. Download and run Microsoft Web Platform Installer (available in http://www.microsoft.com/web/downloads/platform.aspx). Use it to install URL Rewrite 2.1 (or newer) and Application Request Routing 3.0 (or newer) modules. Use the search box to find these components. If you had the IIS Manager open while installing the components, restart the IIS Manager.
  2. Create file C:\inetpub\wwwroot\EnticeServices\web.config with following contents (also create the EnticeServices folder):
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
  <rewrite>
    <rules>
      <rule name="Reverse Proxy to EnticeServices" stopProcessing="true">
        <match url="(.*)" />
        <action type="Rewrite" url="http://localhost:8080/EnticeServices/{R:1}" />
	<serverVariables>
          <set name="HTTP_X_ORIGINAL_ACCEPT_ENCODING" value="{HTTP_ACCEPT_ENCODING}" />
          <set name="HTTP_ACCEPT_ENCODING" value="" />
        </serverVariables>
      </rule>
    </rules>
    <outboundRules>
      <rule name="Change port">
        <match filterByTags="A, Form, Img" pattern="^http://localhost:8080/(.*)" />
        <action type="Rewrite" value="http://localhost/{R:1}" />
      </rule>
    </outboundRules>
  </rewrite>
  </system.webServer>
</configuration>
  1. Create file C:\inetpub\wwwroot\m\web.config with following contents (also create the m folder):
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
  <rewrite>
    <rules>
      <rule name="Reverse Proxy to mobiledash" stopProcessing="true">
        <match url="(.*)" />
        <action type="Rewrite" url="http://localhost:8080/mobiledash/{R:1}" />
	<serverVariables>
          <set name="HTTP_X_ORIGINAL_ACCEPT_ENCODING" value="{HTTP_ACCEPT_ENCODING}" />
          <set name="HTTP_ACCEPT_ENCODING" value="" />
        </serverVariables>
      </rule>
    </rules>
    <outboundRules>
      <rule name="Change port">
        <match filterByTags="A, Form, Img" pattern="^http://localhost:8080/(.*)" />
        <action type="Rewrite" value="http://localhost/{R:1}" />
      </rule>
    </outboundRules>
  </rewrite>
  </system.webServer>
</configuration>
  1. Open Internet Information Services (IIS) Console, click the top level in the left side hierarchy, doubleclick Application Requests Routing Cache, click Server Proxy settins on the right pane, click Enable Proxy and click Apply.
  2. In Internet Information Services (IIS) Console, click EnticeServices folder in the left side hierarchy, double-click URL Rewrite, View Server Variables... variables, and add HTTP_X_ORIGINAL_ACCEPT_ENCODING and HTTP_ACCEPT_ENCODING using the Add button. Do the same for the m folder.
  3. Optional advanced: To harden the security, in GlassFish allow incoming requests only from localhost.
  4. QPR MobileDashboard can now be accessed using url http(s)://SERVER/m/ where SERVER is the hostname of the server.