admin管理员组文章数量:1277901
I have set up a proxy server using Tinyproxy on an Ubuntu VPS, and it works fine in the browser. However, when I try to use it in Node.js with Axios, I keep getting the "Error [ERR_FR_TOO_MANY_REDIRECTS]" error. The Tinyproxy logs don't show any obvious errors, but it seems the request is being redirected to an incorrect URL.
These are the only two lines I have customized in the Tinyproxy config:
DisableViaHeader Yes
Allow 0.0.0.0/0
This is in the logs:
INFO Feb 23 20:23:25.253 [4621]: No upstream proxy for whatismyipaddress
INFO Feb 23 20:23:25.254 [4621]: opensock: opening connection to whatismyipaddress:80
INFO Feb 23 20:23:25.254 [4621]: opensock: getaddrinfo returned for whatismyipaddress:80
CONNECT Feb 23 20:23:25.255 [4621]: Established connection to host "whatismyipaddress" using file descriptor 7.
INFO Feb 23 20:23:25.272 [4621]: Closed connection between local client (fd:6) and remote client (fd:7)
CONNECT Feb 23 20:23:25.316 [4621]: Connect (file descriptor 6): 94.XXXXX.XX
CONNECT Feb 23 20:23:25.317 [4621]: Request (file descriptor 6): GET / HTTP/1.1
INFO Feb 23 20:23:25.318 [4621]: process_request: trans Host GET :80/ for 6
Unfortunately, Squid doesn't work for me either, and not even the normal http requests work with node.js
Edit:
I found that using http.Agent
, the proxy works fine in my code even with axios:
import axios from "axios";
import http from "http";
const agent = new http.Agent({
host: "XXX",
port: XXX,
protocol: "http:",
});
axios.get(";, { httpAgent: agent })
.then(response => console.log(response.data))
.catch(error => console.error("Fehler:", error));
The issue seems to be with Axios, as this is still not working.
I have set up a proxy server using Tinyproxy on an Ubuntu VPS, and it works fine in the browser. However, when I try to use it in Node.js with Axios, I keep getting the "Error [ERR_FR_TOO_MANY_REDIRECTS]" error. The Tinyproxy logs don't show any obvious errors, but it seems the request is being redirected to an incorrect URL.
These are the only two lines I have customized in the Tinyproxy config:
DisableViaHeader Yes
Allow 0.0.0.0/0
This is in the logs:
INFO Feb 23 20:23:25.253 [4621]: No upstream proxy for whatismyipaddress
INFO Feb 23 20:23:25.254 [4621]: opensock: opening connection to whatismyipaddress:80
INFO Feb 23 20:23:25.254 [4621]: opensock: getaddrinfo returned for whatismyipaddress:80
CONNECT Feb 23 20:23:25.255 [4621]: Established connection to host "whatismyipaddress" using file descriptor 7.
INFO Feb 23 20:23:25.272 [4621]: Closed connection between local client (fd:6) and remote client (fd:7)
CONNECT Feb 23 20:23:25.316 [4621]: Connect (file descriptor 6): 94.XXXXX.XX
CONNECT Feb 23 20:23:25.317 [4621]: Request (file descriptor 6): GET https://whatismyipaddress/ HTTP/1.1
INFO Feb 23 20:23:25.318 [4621]: process_request: trans Host GET http://whatismyipaddress:80https://whatismyipaddress/ for 6
Unfortunately, Squid doesn't work for me either, and not even the normal http requests work with node.js
Edit:
I found that using http.Agent
, the proxy works fine in my code even with axios:
import axios from "axios";
import http from "http";
const agent = new http.Agent({
host: "XXX",
port: XXX,
protocol: "http:",
});
axios.get("http://api", { httpAgent: agent })
.then(response => console.log(response.data))
.catch(error => console.error("Fehler:", error));
The issue seems to be with Axios, as this is still not working.
Share Improve this question edited Feb 23 at 22:42 UsAA12 asked Feb 23 at 20:29 UsAA12UsAA12 515 bronze badges1 Answer
Reset to default 0The issue lies in axios, i didnt know, what axios has sometimes problems using a http
Proxys with https://
requests.
A good workaround is found here at github:
https://github/axios/axios/issues/4531#issuecomment-1081264893
const axios = require('axios');
const { HttpProxyAgent, HttpsProxyAgent } = require('hpagent')
const httpAgent = new HttpProxyAgent({
proxy: 'proxy url'
})
const httpsAgent = new HttpsProxyAgent({
proxy: 'proxy url'
})
const instance = axios.create({ httpAgent, httpsAgent });
instance.post('http://example')
本文标签: proxyTinyProxy with AxiosToo Many Redirects Https ErrorStack Overflow
版权声明:本文标题:proxy - TinyProxy with Axios - Too Many Redirects Https Error - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741302945a2371200.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论