Setting up UpSource behind IIS Reverse Proxy for HTTPS ~ TypeError: Failed to fetch

Hello everyone,

I am trying to set up UpSource, along with YouTrack, TeamCity and Hub, over https on a single server using a reverse IIS  Proxy.

I have already succeeded in setting up TeamCity and Hub. However I  am still having trouble with YouTrack and UpSource.

Regarding UpSource, the situation is as follows:

The http version of UpSource is located at http://server.company.com:8081/upsource and works fine. I want it to be accessible via https://server.company.com/upsource. However, while it is possible to access UpSource via the https address, the connection is immediately interrupted and the following error message comes up:

Backend is not available

TypeError: Failed to fetch

This error is weird and confusing, considering that the backend obviously is available and running since http://server.company.com:8081/upsource works perfectly.

As for my configuration, I set it up mostly following the steps as outlined in https://www.jetbrains.com/help/upsource/proxy-configuration.html , making amends where needed to account for the fact that we have four JetBrains services running on a single server and over the same IIS Reverse Proxy.

The current web.config for the IIS Proxy reads as follows:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <clear />
                <rule name="Reverse Proxy to TeamCity" stopProcessing="true">
                    <match url="^teamcity(.*)" />
                    <action type="Rewrite" url="http://server.company.com{R:1}" />
                </rule>
                <rule name="Reverse Proxy to Hub" stopProcessing="true">
                    <match url="^hub(.*)" />
                    <action type="Rewrite" url="http://server.company.com:8082/hub{R:1}" />
                    <serverVariables>
                        <set name="HTTP_X_FORWARDED_HOST" value="{HTTP_HOST}" />
                        <set name="HTTP_X_FORWARDED_SCHEMA" value="https" />
                        <set name="HTTP_X_FORWARDED_PROTO" value="https" />
                    </serverVariables>
                </rule>
                <rule name="Reverse Proxy to YouTrack" stopProcessing="true">
                    <match url="^youtrack(.*)" />
                    <action type="Rewrite" url="http://server.company.com:8080/youtrack{R:1}" />
                    <serverVariables>
                        <set name="HTTP_X_FORWARDED_HOST" value="{HTTP_HOST}" />
                        <set name="HTTP_X_FORWARDED_SCHEMA" value="https" />
                        <set name="HTTP_X_FORWARDED_PROTO" value="https" />
                    </serverVariables>
                </rule>
               <rule name="Reverse Proxy to UpSource" stopProcessing="true">
                    <match url="^upsource(.*)" />
                    <action type="Rewrite" url="http://server.company.com:8081/upsource{R:1}" />
                    <serverVariables>
                        <set name="HTTP_X_FORWARDED_HOST" value="{HTTP_HOST}" />
                        <set name="HTTP_X_FORWARDED_SCHEMA" value="https" />
                        <set name="HTTP_X_FORWARDED_PROTO" value="https" />
                    </serverVariables>
               </rule>
                <rule name="Reverse Proxy to Collaboration General" stopProcessing="true">
                    <match url="(.*)" />
                    <action type="Rewrite" url="http://server.company.com/{R:1}" />
                </rule>
            </rules>
        </rewrite>
        <security>
            <requestFiltering>
                <requestLimits maxUrl="6144" maxQueryString="4096" />
            </requestFiltering>
        </security>
    </system.webServer>
</configuration>

As I mentioned, this already works fine for TeamCity and Hub. However, for UpSource, there seems to be something still missing, which is likely related to the "TypeError: Failed to fetch". I've tried looking that up, but could not find any helpful information.

If anyone has any ideas how to resolve this, I'd be more than happy to listen.

Thanks in advance,

Kira Resari

2 comments

Okay, so I figured out how to do this:

The above configuration of the web.config is actually correct. However, the following steps need to be performed in addition, and in the correct order:

NOTE: All commands beginning with `hub.bat` need to be performed on the `hub.bat` file in `[Hub Installation Directory]\bin` and all commands beginning with `upsource.bat` need to be performed on the `upsource.bat` file in `[UpSource Installation Directory]\bin`.

    upsource.bat stop
    hub.bat stop
    
    hub.bat configure --listen-port 8082 --base-url https://server.company.com/hub
    upsource.bat configure --listen-port 8081 --base-url=https://server.company.com/upsource --hub-url=https://server.company.com/hub/hub
    
    hub.bat start
    upsource.bat start --J-Dbundle.websocket.compression.enabled=false


NOTE: I don't know why, but Hub  appends an extra /hub after its base address, that's why the hub-url setting for UpSource ends with `/hub/hub`.

After that, all I needed to do was add the redirection URL to the list of allowed redirection URLs for UpSource in Hub > Settings > Services > UpSource, and now it works perfectly.

Well, almost perfectly. Whenever the server gets restarted I need to manually restart UpSource since I've not yet figured out a way to register upsource as a service with the `--J-Dbundle.websocket.compression.enabled=false` parameter, but apart from that, everything works perfectly.

0

Note: on IIS 8.5 set HTTP1.1 at ARR PROXY-Settings. Otherwise the websocket connects, but there's no communication.

upsource v. upsource-2018.2.1291

https://www.jetbrains.com/help/upsource/proxy-configuration.html#IISreverseProxy

0

Please sign in to leave a comment.