запустить узел за прокси - PullRequest
0 голосов
/ 08 мая 2019

У меня есть простой код для определения идентификатора учетной записи aws и проверки его соответствия идентификатору в файле json

$ cat sample.json

{
  "account_id": "123456789012",
  "name": "foo"
}

код узла

#!/usr/bin/env node

const fs = require('fs');
const util = require('util');
const aws = require('aws-sdk');

const sts = new aws.STS();

const file = 'sample.json';
const content = fs.readFileSync(file);
const jsonContent = JSON.parse(content);

sts.getCallerIdentity({}, (err, data) => {
  if (err) {
    console.log('can not get aws account id');
    process.exit(-1);
  } else if (data.Account !== jsonContent.account_id) {
    console.log(util.format('aws account id does not match its configuration file %s , exist ...', file));
    process.exit(-1);
  } else {
    console.log('account matched');
  }
});

Если я запускаю его прямо на моем ноутбуке, он работает, покажите «Подходящий аккаунт»

Но когда я запускаю в докере с корпоративным прокси (I can curl public url in docker, so the proxy setting is no issue here), он завершается с ошибкой

can not get aws account id

npm ERR! code ELIFECYCLE
npm ERR! errno 255
npm ERR! sample@1.0.0 account: `node a.js`
npm ERR! Exit status 255
npm ERR!
npm ERR! Failed at the sample@1.0.0 account script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2019-05-08T05_45_56_807Z-debug.log

Нет полезной информации в /root/.npm/_logs/2019-05-08T05_45_56_807Z-debug.log

Я могу curl публичный URL в работающем контейнере.

bash-4.3# curl www.google.com|more
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   676    0   676    0     0   3907      0 --:--:-- --:--:-- --:--:--  3885
<!doctype html><html itemscope="" itemtype="http://schema.org/WebPage" lang="en-AU"><head><meta content="text/
...

Так что я полагаю, это потому, что прокси заблокировал доступ. Что я должен сделать, чтобы это исправить?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...