Unable to download artifacts - HTTP 302 loop

in have project, that is successfully building artifacts, but when i click on download link i get ERR_TOO_MANY_REDIRECTS

example of link, that i can click on http://build.cstechnologies.eu/favorite/projects?mode=builds page :

http://build.cstechnologies.eu/repository/download/Centaur_50/115454:id/client/NHibernate.dll

which is redirected to:

http://artifacts.cstechnologies.eu/presignedTokenAuth/ca37d705-6f19-46e1-8a7c-fd5fb6f8a0fe/repository/download/Centaur_50/115454:id/client/NHibernate.dll

and this one returns http 302 to itself → infinite loop

 

my teamcity server is running on 127.0.0.1:9000 and im using IIS ARR3 to route requests from

http://build.cstechnologies.eu/ and http://artifacts.cstechnologies.eu/ - see web.config fbellow for details

 

any idea what could be causing this?

---

web.config:

```
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
   <system.web>
       <!-- 100 MB in kilobytes -->
       <httpRuntime maxRequestLength="102400" />
  </system.web>
   <system.webServer>
       <security>
           <requestFiltering>
               <!-- 100 MB in bytes -->
               <requestLimits maxAllowedContentLength="104857600" maxQueryString="4096" />
               <denyUrlSequences>
                   <clear />
               </denyUrlSequences>
               <fileExtensions allowUnlisted="true">
                   <clear />
               </fileExtensions>
        </requestFiltering>
       </security>
       <handlers>
           <clear />
       </handlers>
       <rewrite>
           <rules>
               <clear />
               <rule name="http://build.cstechnologies.eu" stopProcessing="true">
                   <match url="(.*)" />
                   <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                       <add input="{HTTP_HOST}" pattern="build.cstechnologies.eu" />
                       <!-- <add input="{HTTPS}" pattern="OFF" /> -->
                   </conditions>
                   <action type="Rewrite" url="http://127.0.0.1:9000/{R:0}" />
                   <serverVariables>
                   </serverVariables>
               </rule>
               <rule name="http://artifacts.cstechnologies.eu" stopProcessing="true">
                   <match url="(.*)" />
                   <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                       <add input="{HTTP_HOST}" pattern="artifacts.cstechnologies.eu" />
                       <!-- <add input="{HTTPS}" pattern="OFF" /> -->
                   </conditions>
                   <action type="Rewrite" url="http://127.0.0.1:9000/{R:0}" />
                   <serverVariables>
                   </serverVariables>
               </rule>
           </rules>
       </rewrite>
   </system.webServer>
</configuration>
```
 

0
11 comments
Hi Marek,

Please help me understand the desired scenario of your configuration. Why do you need 2 URLs for accessing TeamCity, and why do you need a redirect from build to artifacts if they all access the same TeamCity server? 
In this case, the desired scenario is that build should redirect to artifacts, and artifacts should redirect to localhost. Is this correct?

Best regards,
Anton
0

because teamcity requires it:

from  /admin/admin.html?item=serverConfigGeneral page:

Server URL: http://build.cstechnologies.eu/ 

Artifacts URL: http://artifacts.cstechnologies.eu/   ← cannot use Server URL here 

 

 

 

0
Dear Marek,

I see. I'm sorry for the confusion here.
The most likely cause of the issue is IIS misconfiguration, which can't be affected from the TeamCity server's side. I looked through possible causes of similar issues on IIS forums, etc., and would like to recommend the following steps:
1. Uncheck the "Reverse rewrite host in response headers" checkbox in ARR proxy settings (they should be in IIS > Application Request Routing Cache > Server Proxy Settings, but can be in a different location depending on the IIS version).
2. If it doesn't help, the Failed Request Tracing may help with troubleshooting the issue: https://learn.microsoft.com/en-us/iis/extensions/url-rewrite-module/using-failed-request-tracing-to-trace-rewrite-rules.

Best regards,
Anton
0

after some more investigation i discovered that if i post correct request to url (clicked on artifact in browser and then changed host part  manually using fiddler)

http://127.0.0.1:9000/presignedTokenAuth/0492294d-71c3-45c0-8ab8-3940ad19f57b/repository/download/Zeus_50/120474:id/net40/DevExpress.Data.v14.1.dll

server returns http 302 to url, that is translated by IIS back to ^

HTTP/1.1 302
TeamCity-Node-Id: MAIN_SERVER
Location: http://artifacts.cstechnologies.eu:80/presignedTokenAuth/0492294d-71c3-45c0-8ab8-3940ad19f57b/repository/download/Zeus_50/120474:id/net40/DevExpress.Data.v14.1.dll
Content-Length: 0
Date: Fri, 05 Apr 2024 15:04:05 GMT
Keep-Alive: timeout=60
Connection: keep-alive

this happens even if i completely shut down entire IIS - in that case i will get HTTP 404

i also ‘just for fun’ tryied to set Artifacts URL: in TC configuration to http://127.0.0.1:9000/ but that didnt work either …

0
Dear Marek,

Could you let me know the results of the steps from my previous message? Did you get anything from the Failed Request Tracing? It seems that IIS redirects may be misconfigured, and tracing should help determine the steps in which they are failing. 

Best regards,
Anton
0

i do not have access to server atm, but from memory it went like this:

1. client create HTTP GET http://build.cstechnologies.eu/repository/download/Zeus_50/121398:id/net40/DevExpress.Data.v14.1.dll
2. IIS site handles that request and using ARR redirect it to http://127.0.0.1:9000/repository/download/Zeus_50/121398:id/net40/DevExpress.Data.v14.1.dll

3. TeamCity server handles that one and returns HTTP 302 http://artifacts.cstechnologies.eu:80/presignedTokenAuth/0492294d-71c3-45c0-8ab8-3940ad19f57b/repository/download/Zeus_50/120474:id/net40/DevExpress.Data.v14.1.dll

4. client browser follow redirect …

5. IIS site (same site as in point 2.) handles that request and using ARR redirect it to http://127.0.0.1:9000/presignedTokenAuth/0492294d-71c3-45c0-8ab8-3940ad19f57b/repository/download/Zeus_50/120474:id/net40/DevExpress.Data.v14.1.dll

6. TeamCity server handles this request and returns HTTP 302 http://artifacts.cstechnologies.eu:80/presignedTokenAuth/0492294d-71c3-45c0-8ab8-3940ad19f57b/repository/download/Zeus_50/120474:id/net40/DevExpress.Data.v14.1.dll

7. goto step 4 until browser stops it with TOO_MANY_REDIRECTS error

---

on IIS i have web site that is listening on  http://build.cstechnologies.eu,  ws://build.cstechnologies.eu and  http://artifacts.cstechnologies.eu and redirects all requests to teamcity listening on 127.0.0.1:9000  (web config is posted couple of posts above - without ws:// redirect, but that basically clone of http:// redirect)

PS: i dont think it is caused by iis - it was happening even when i turned IIS off and made request in fiddler to address from point 5.

my guess is that artifacts url handler is doing something like this: (to prevent use of ‘wrong’ url to download artifacts)

var ARTIFACTS_URL_FROM_CONFIGURATION = "http://artifacts.cstechnologies.eu";
if (Request.Url.GetLeftPart(UriPartial.Authority) ≠ ARTIFACTS_URL_FROM_CONFIGURATION ) {
    Response.Redirect(ARTIFACTS_URL_FROM_CONFIGURATION  + request.Url.Query);
}

i think its because both  http://build.cstechnologies.eu/… and http://artifacts.cstechnologies.eu/… are redirected to http://127.0.0.1:9000/… 

 

0
Dear Marek,

Please check the following:
1. Check if the `teamcity.internal.domainIsolation.serveArtifactsOnlyFromArtifactsUrl=false` internal property helps as a workaround. Server restart is not required. Internal properties: https://www.jetbrains.com/help/teamcity/2024.03/server-startup-properties.html#TeamCity+Internal+Properties.
2. Collect the following information:
- If the internal property `teamcity.internal.domainIsolation.serveArtifactsOnlyFromArtifactsUrl=false` is set, remove it.
- Ensure the artifact domain isolation option is enabled (Administration > Global Settings > Artifacts Domain Isolation).
- Enable the `debug-all` logging preset: https://www.jetbrains.com/help/teamcity/teamcity-monitoring-and-diagnostics.html#Logging+Presets.
- Download an artifact to reproduce the too many redirects problem.
- Return the logging preset back to `<Default>`.
- Upload the `teamcity-auth.log*` files covering the time of the issue reproduction to https://uploads.jetbrains.com/ and share the upload ID.
- Revert the changes in steps 1 and 2, if any were made.

Best regards,
Anton
0

updated teamcity to latest version (build 156166), then enabled debug-all, tried to download random artifact and uploaded 2024_04_12_29Wr8Npy3AuZ53Xz4VU3yj (file: teamcity-auth.log) - (before upload i removed all entries before my download  attempt)

 

0
Dear Marek,

Could you confirm the result of step 1 from my previous message? And for the shared teamcity-auth.log file, did you check all the points listed in step 2? Thank you!

Best regards,
Anton
0

i misread step 1 - when i added teamcity.internal.domainIsolation.serveArtifactsOnlyFromArtifactsUrl=false artifact file could be downloaded

i did check all points in step 2

 

so i think my issue is resolved …

0
Dear Marek,

Thank you for checking. This can be used as a current workaround, but this issue has already been reported in our issue tracker, and the permanent solution has a current ETA of 2024.03.1 (the next minor release): https://youtrack.jetbrains.com/issue/TW-85963/Infinite-redirect-on-some-of-Artifact-Isolation-setups. Please subscribe to the issue to receive updates on it.

Best regards,
Anton
0

Please sign in to leave a comment.