简体   繁体   English

在IIS反向代理后面为HTTPS设置UpSource〜TypeError:无法获取

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

I am trying to set up UpSource, along with YouTrack, TeamCity and Hub, over https on a single server using a reverse IIS Proxy. 我正在尝试使用反向IIS代理在单个服务器上通过https设置UpSource,YouTrack,TeamCity和Hub。

The situation is as follows: 情况如下:

The http version of UpSource is located at http://server.company.com:8081/upsource and works fine. UpSource的http版本位于http://server.company.com:8081/upsource ,可以正常工作。 I want it to be accessible via https://server.company.com/upsource . 我希望可以通过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: 但是,虽然可以通过https地址访​​问UpSource,但连接会立即中断,并出现以下错误消息:

Backend is not available

TypeError: Failed to fetch

I find this error to be weird and confusing, considering that the backend appears to be available and running since http://server.company.com:8081/upsource works perfectly. 考虑到后端似乎可用并且正在运行,因为http://server.company.com:8081/upsource完美运行,因此我发现此错误很奇怪且令人困惑。

As for my configuration, I set it up mostly following the steps as outlined in the documentation , 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. 对于我的配置,我主要按照文档中概述的步骤进行设置 ,在需要进行修正的地方考虑到我们有四个JetBrains服务在单个服务器上和同一IIS反向代理上运行。

The current web.config for the IIS Proxy reads as follows: IIS代理的当前web.config内容如下:

<?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. 正如我提到的,这对于TeamCity和Hub来说已经可以正常工作了。 However, for UpSource, there seems to be something still missing, which is likely related to the "TypeError: Failed to fetch". 但是,对于UpSource,似乎仍然缺少某些内容,这很可能与“ TypeError:无法获取”有关。 I've tried looking that up, but could not find any helpful information thus far . 我尝试过查找,但是到目前为止找不到任何有用的信息。

If anyone has any ideas how to resolve this, I'd be more than happy to get additional input on this 如果有人对如何解决这个问题有任何想法,我很乐意在此方面获得其他意见

Okay, so I figured out how to do this: 好的,所以我想出了办法:

The above configuration of the web.config is actually correct. web.config的上述配置实际上是正确的。 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 . 注:开头的所有命令hub.bat需要在执行hub.bat文件[Hub Installation Directory]\\bin ,所有的命令开始与upsource.bat必须在执行upsource.bat文件[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 . 注意:我不知道为什么,但是Hub会在其基址之后附加一个额外的/ hub,这就是为什么UpSource的hub-url设置以/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. 之后,我需要做的就是将重定向URL添加到“集线器”>“设置”>“服务”>“ UpSource”中UpSource允许的重定向URL列表中,现在它可以正常工作了。

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. 每当服务器重新启动时,我都需要手动重新启动UpSource,因为我还没有找到使用--J-Dbundle.websocket.compression.enabled=false参数将--J-Dbundle.websocket.compression.enabled=false注册为服务的--J-Dbundle.websocket.compression.enabled=false ,但是除此之外,一切完美地工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM