问题
My curl command seems to redirect to the same place indefinitely. --max-redir is set to 3 below to make the output easier to read, there does not seem to be a difference if I allow 50 redirects.
$ curl --verbose --location --max-redirs 3 --ntlm --user "$USERNAME:$PASSWORD" https://my_application.intranet.net/MyApp
* About to connect() to my_application.intranet.net port 443 (#0)
* Trying 10.0.0.139...
* Connected to my_application.intranet.net (10.0.0.139) port 443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
* CAfile: /etc/pki/tls/certs/ca-bundle.crt
CApath: none
* SSL connection using TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA
* Server certificate:
* subject: CN=my_application.intranet.net,OU=WU - Web Hosting,O=...
* start date: Apr 06 00:00:00 2020 GMT
* expire date: Apr 06 23:59:59 2022 GMT
* common name: my_application.intranet.net
* issuer: CN=COMODO RSA Organization Validation Secure Server CA,O=...
* Server auth using NTLM with user 'User'
> GET /MyApp HTTP/1.1
> Authorization: NTLM TlRMTVNTUAABAAAABoIIAAAAAAAAAAAAAAAAAAAAAAA=
> User-Agent: curl/7.29.0
> Host: my_application.intranet.net
> Accept: */*
>
< HTTP/1.1 401 Unauthorized
< Content-Type: text/html; charset=us-ascii
< Server: Microsoft-HTTPAPI/2.0
< WWW-Authenticate: NTLM TlRMTVNTUAACAAAABwAHADgAAAAGgokCRq5F/qQskfcAAAAAAAAAAK4ArgA/AAAABgOAJQAAAA9IUUlOVEwxAgAOAEgAUQBJAE4AVABMADEAAQAcAFcAVQBUAEUAQQBNAEUAVgA5AFcAQgAwADAAMQAEABYASABRAEkATgBUAEwAMQAuAGMAbwBtAAMANAB3AHUAdABlAGEAbQBlAHYAOQBXAEIAMAAwADEALgBoAHEAaQBuAHQAbAAxAC4AYwBvAG0ABQAWAEgAUQBJAE4AVABMADEALgBjAG8AbQAHAAgA8V6tXHTc1gEAAAAA
< Date: Sun, 27 Dec 2020 17:18:58 GMT
< Content-Length: 341
<
* Ignoring the response-body
* Connection #0 to host my_application.intranet.net left intact
* Issue another request to this URL: 'https://my_application.intranet.net/MyApp'
* Found bundle for host my_application.intranet.net: 0x8b4fb0
* Re-using existing connection! (#0) with host my_application.intranet.net
* Connected to my_application.intranet.net (10.0.0.139) port 443 (#0)
* Server auth using NTLM with user 'User'
> GET /MyApp HTTP/1.1
> Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAAFAAUAHAAAAAQABAAhAAAAAAAAAAAAAAABoKJAlEjznrpL4kjAAAAAAAAAAAAAAAAAAAAAOa+8rUwlSu2YqYy1p3J0HHzw0uwDqzvhlNfSmlyYV9JbnRlcm5hbEF1ZGl0aXAtMTAtMzktMTgyLTI0Nw==
> User-Agent: curl/7.29.0
> Host: my_application.intranet.net
> Accept: */*
>
< HTTP/1.1 302 Found
< Content-Type: text/html; charset=utf-8
< Location: /MyApp/
< Server: MyApp Server
< X-Frame-Options: SAMEORIGIN
< X-Content-Type-Options: nosniff
< Date: Sun, 27 Dec 2020 17:18:58 GMT
< Content-Length: 130
<
* Ignoring the response-body
* Connection #0 to host my_application.intranet.net left intact
* Issue another request to this URL: 'https://my_application.intranet.net/MyApp/'
* Found bundle for host my_application.intranet.net: 0x8b4fb0
* Re-using existing connection! (#0) with host my_application.intranet.net
* Connected to my_application.intranet.net (10.0.0.139) port 443 (#0)
* Server auth using NTLM with user 'User'
> GET /MyApp/ HTTP/1.1
> User-Agent: curl/7.29.0
> Host: my_application.intranet.net
> Accept: */*
>
< HTTP/1.1 302 Found
< Cache-Control: private
< Content-Type: text/html; charset=utf-8
< Location: /MyApp/
< Set-Cookie: ASP.NET_SessionId=swt4ivbaajalrwfdm0jshof3; path=/; secure; HttpOnly; SameSite=Lax
< Set-Cookie: MyApp_Cookie=ConnectionTitle=DELwLGx+KbrtS0gKvmretg==&IsConnectionTitleSet=True&IsLogOff=False&CurrentOrganization=ELx658BVmiesDFQg7w5RtA==&IsOrganizationRequired=YBfC/taoB3Ll19UPqF9IEA==; path=/; secure; HttpOnly
< Set-Cookie: .MyApp_SSO_Cookie=ConnectionTitle=DELwLGx+KbrtS0gKvmretg==&IsConnectionTitleSet=True&IsLogOff=True&CurrentOrganization=ELx658BVmiesDFQg7w5RtA==&IsOrganizationRequired=YBfC/taoB3Ll19UPqF9IEA==; path=/; secure; HttpOnly
< Server: MyApp Server
< Persistent-Auth: true
< X-Frame-Options: SAMEORIGIN
< X-Content-Type-Options: nosniff
< Date: Sun, 27 Dec 2020 17:18:58 GMT
< Content-Length: 130
<
* Ignoring the response-body
* Connection #0 to host my_application.intranet.net left intact
* Issue another request to this URL: 'https://my_application.intranet.net/MyApp/'
* Found bundle for host my_application.intranet.net: 0x8b4fb0
* Re-using existing connection! (#0) with host my_application.intranet.net
* Connected to my_application.intranet.net (10.0.0.139) port 443 (#0)
* Server auth using NTLM with user 'User'
> GET /MyApp/ HTTP/1.1
> User-Agent: curl/7.29.0
> Host: my_application.intranet.net
> Accept: */*
>
< HTTP/1.1 302 Found
< Cache-Control: private
< Content-Type: text/html; charset=utf-8
< Location: /MyApp/
< Set-Cookie: ASP.NET_SessionId=v4cjtwk0bmtytcxlkd1w1gmb; path=/; secure; HttpOnly; SameSite=Lax
< Set-Cookie: MyApp_Cookie=ConnectionTitle=DELwLGx+KbrtS0gKvmretg==&IsConnectionTitleSet=True&IsLogOff=False&CurrentOrganization=ELx658BVmiesDFQg7w5RtA==&IsOrganizationRequired=YBfC/taoB3Ll19UPqF9IEA==; path=/; secure; HttpOnly
< Set-Cookie: .MyApp_SSO_Cookie=ConnectionTitle=DELwLGx+KbrtS0gKvmretg==&IsConnectionTitleSet=True&IsLogOff=True&CurrentOrganization=ELx658BVmiesDFQg7w5RtA==&IsOrganizationRequired=YBfC/taoB3Ll19UPqF9IEA==; path=/; secure; HttpOnly
< Server: MyApp Server
< Persistent-Auth: true
< X-Frame-Options: SAMEORIGIN
< X-Content-Type-Options: nosniff
< Date: Sun, 27 Dec 2020 17:18:58 GMT
< Content-Length: 130
<
* Ignoring the response-body
* Connection #0 to host my_application.intranet.net left intact
* Maximum (3) redirects followed
curl: (47) Maximum (3) redirects followed
来源:https://stackoverflow.com/questions/65468536/how-to-get-curl-to-narrow-to-correct-redirect