节点请求模块忽略代理并在请求任何HTTPS地址时公开服务器IP。请求HTTP地址时,一切正常。怎么了?
const request = require('request'),
zlib = require('zlib'),
fs = require('fs')
var cb = 1
request.get({
timeout: 45000,
gzip: true,
pool: false,
followRedirect: false,
headers: {},
url: 'https://api.ipify.org?format=json',
proxy: '111.64.234.5:31218'
}).on('error', function (err) {
console.log(err + 'ERRRRRRRORRRRRR')
}).on('response', function (res) {
var chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
var buffer = Buffer.concat(chunks);
var encoding = res.headers['content-encoding'];
if (cb) {
cb = 0
if (encoding == 'gzip') {
zlib.gunzip(buffer, function (err, decoded) {
console.log(decoded.toString())
});
} else if (encoding == 'deflate') {
zlib.inflateRaw(buffer, function (err, decoded) { //inflate instead ???
console.log(decoded.toString())
})
} else {
console.log(buffer.toString())
}
}
});
})
您可以尝试任何IP:PORT作为代理。有什么想法吗?