-1

Our internal web server is running IIS, with the main site powered by aspNetCore and launched as MainWeb.exe.

We would like to deploy a new REST API built with Quarkus as a native image (quarkus-rest-api.exe) and run it on the same web server. Is it possible to execute quarkus-rest-api.exe using IIS as a reverse proxy via HttpPlatformHandler?

The services are configured to run on the following ports:

  • Main site: Port 80
  • API: Port 8080

We want the URLs to be as follows:

  • Main site: http://10.1.1.2/
  • API: http://10.1.1.2/api

The following components have already been installed:

  • httpPlatformHandler_amd64.msi
  • requestRouter_amd64.msi
  • rewrite_amd64_ja-JP.msi

Directory Structure:

D:
├MainApp
│ ├・・・
│ └web.config
└QuarkusAPI(sub application)
  ├・・・
  └web.config

Main Site web.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <location path="." inheritInChildApplications="false">
    <system.webServer>
      <httpErrors errorMode="Detailed" />
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
      </handlers>
      <aspNetCore processPath=".\MainWeb.exe" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
      <rewrite>
        <rules>
          <rule name="QuarkusAPI" stopProcessing="true">
            <match url="^api/(.*)" />
            <action type="Rewrite" url="http://localhost:8080/{R:1}" logRewrittenUrl="true" />
          </rule>
        </rules>
      </rewrite>
    </system.webServer>
  </location>
</configuration>

Sub-application web.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="QuarkusAPIHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
    </handlers>
    <httpPlatform processPath="D:\QuarkusAPI\quarkus-rest-api.exe" stdoutLogEnabled="true" stdoutLogFile="D:\QuarkusAPI\logs\stdout.log" startupTimeLimit="600">
    </httpPlatform>
    <httpErrors errorMode="Detailed" />
  </system.webServer>
</configuration>

attempt:

attempt 1: When accessing the API with the above configuration, no response is returned. It seems that HttpPlatformHandler is not working, and quarkus-rest-api.exe is not being executed.

attempt 2: However, when I manually execute quarkus-rest-api.exe and disable both the sub-application and HttpPlatformHandler, the API responds correctly.

attempt 3: When I kept the sub-application's web.config settings unchanged and modified the url in the Rewrite section of the main site's web.config as follows, the HttpPlatformHandler worked correctly: <action type="Rewrite" url="/api/{R:1}" logRewrittenUrl="true" />

Question: Is it possible to configure both rewrite and httpPlatform at the same time? If so, how can I achieve this?

Would it be a more common and appropriate approach to manage quarkus-rest-api.exe using a Windows Service + IIS reverse proxy setup, rather than HttpPlatformHandler, to keep it running at all times while handling reverse proxy functionality?

If anyone could help me resolve this issue, I would greatly appreciate it.

2
  • docs.lextudio.com/blog/… If you check out any examples in the References section, you will see your HttpPlatformHandler setting is invalid. Commented Jan 7 at 15:27
  • @LexLi I sincerely appreciate your assistance. I have reviewed the reference document titled "Java Example by Microsoft." However, as this case involves a native image, the configuration example appears to differ, and I was unable to identify what might be incorrect. For your reference, I have also added attempt 3 to the question. Commented Jan 8 at 2:11

1 Answer 1

0

I wanted to document the following changes that resolved the issue, for reference:

  1. Modify the Main Site's Rewrite Rule Update the rewrite rule to point to the sub-application's virtual path instead of localhost:8080. For example:

    <action type="Rewrite" url="/api/{R:1}" logRewrittenUrl="true" />

  2. Update the Configuration In the arguments section of the configuration, update it to pass -Dquarkus.http.port=%HTTP_PLATFORM_PORT% to the Quarkus executable (in the sub-application's web.config settings):

    arguments="-Dquarkus.http.port=%HTTP_PLATFORM_PORT%"

Note: HttpPlatformHandler sets an environment variable called HTTP_PLATFORM_PORT (or sometimes a similar variable). Your Quarkus app should read this variable to determine the listening port. The default Quarkus port 8080 cannot be used in this configuration.

  1. Align the Quarkus Root Path with the IIS Folder Name Set the Quarkus root path to match the IIS folder name by adding the following to your application.properties:

    quarkus.http.root-path=/api

However..., further investigation revealed the following:

HttpPlatformHandler was primarily intended for lightweight scenarios where you only want a process up when there is traffic. It’s essentially bridging non-IIS processes into IIS, much like older versions did for PHP, Node.js, etc.

To be honest, it seems HttpPlatformHandler was never really cut out for a perpetually running REST API service in the first place. It’s a bit like expecting a part-time temp to pull an all-nighter—things don’t tend to go smoothly.

As an alternative, I am considering running quarkus-rest-api.exe as a Windows Service and setting up a reverse proxy using URL Rewrite and ARR.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.