【问题标题】:Run Node.js & Meteor behind SOCKS proxy在 SOCKS 代理后面运行 Node.js 和 Meteor
【发布时间】:2015-12-16 14:31:27
【问题描述】:

我正在连接到许多网站被阻止的国家/地区的互联网。所以连接的方法是:

ssh -D 3030 root@46.101.111.333

然后我在 Network Preferences 中进行了配置

这样我就可以使用我的浏览器在任何地方进行连接。没问题。但是当我想用终端安装 NPM 模块或 Meteor.js 插件时,我得到一个错误。

在 NPM 中:

errno: 'ECONNREFUSED' 如果您使用代理,请确保正确设置了“代理”配置。请参阅:'npm 帮助配置'

在流星中:

无法更新包目录(您是否离线?)

如果您在代理后面使用 Meteor,请设置 HTTP_PROXY 和 HTTPS_PROXY 环境变量或查看此页面了解更多详情: https://github.com/meteor/meteor/wiki/Using-Meteor-behind-a-proxy


我同时关注了 Meteor 和 NPM 文档。

流星

export HTTP_PROXY=http://root:password@46.101.111.333:3030
export HTTPS_PROXY=http://root:password@46.101.111.333:3030
meteor update

NPM

npm config set proxy http://root:password@46.101.111.333:3030
npm config set https-proxy http://root:password@46.101.111.333:3030

还有其他一些...

请帮忙,我还需要做什么.. 是 ssh 还是代理特定的问题。我的设置正确吗?

【问题讨论】:

标签: node.js meteor proxy npm


【解决方案1】:

假设您的 SOCKS5 代理是:127.0.0.1:3030 ...

  • 通过自制软件安装proxychains-ng
  • 创建~/.proxychains/proxychains.conf

例如,您可能需要添加一行:

socks5 127.0.0.1 3030

关注[ProxyList]

# proxychains.conf  VER 4
#
#        HTTP, SOCKS4, SOCKS5 tunneling proxifier with DNS.
#   

# The option below identifies how the ProxyList is treated.
# only one option should be uncommented at time,
# otherwise the last appearing option will be accepted
#
#dynamic_chain
#
# Dynamic - Each connection will be done via chained proxies
# all proxies chained in the order as they appear in the list
# at least one proxy must be online to play in chain
# (dead proxies are skipped)
# otherwise EINTR is returned to the app
#
strict_chain
#
# Strict - Each connection will be done via chained proxies
# all proxies chained in the order as they appear in the list
# all proxies must be online to play in chain
# otherwise EINTR is returned to the app
#
#random_chain
#
# Random - Each connection will be done via random proxy
# (or proxy chain, see  chain_len) from the list.
# this option is good to test your IDS :)

# Make sense only if random_chain
#chain_len = 2

# Quiet mode (no output from library)
#quiet_mode

# Proxy DNS requests - no leak for DNS data
proxy_dns 

# set the class A subnet number to usefor use of the internal remote DNS mapping
# we use the reserved 224.x.x.x range by default,
# if the proxified app does a DNS request, we will return an IP from that range.
# on further accesses to this ip we will send the saved DNS name to the proxy.
# in case some control-freak app checks the returned ip, and denies to 
# connect, you can use another subnet, e.g. 10.x.x.x or 127.x.x.x.
# of course you should make sure that the proxified app does not need
# *real* access to this subnet. 
# i.e. dont use the same subnet then in the localnet section
#remote_dns_subnet 127 
#remote_dns_subnet 10
remote_dns_subnet 224

# Some timeouts in milliseconds
tcp_read_time_out 15000
tcp_connect_time_out 8000

# By default enable localnet for loopback address ranges
# RFC5735 Loopback address range
localnet 127.0.0.0/255.0.0.0
# RFC1918 Private Address Ranges
# localnet 10.0.0.0/255.0.0.0
# localnet 172.16.0.0/255.240.0.0
# localnet 192.168.0.0/255.255.0.0


# Example for localnet exclusion
## Exclude connections to 192.168.1.0/24 with port 80
# localnet 192.168.1.0:80/255.255.255.0

## Exclude connections to 192.168.100.0/24
# localnet 192.168.100.0/255.255.255.0

## Exclude connections to ANYwhere with port 80
# localnet 0.0.0.0:80/0.0.0.0

# ProxyList format
#       type  host  port [user pass]
#       (values separated by 'tab' or 'blank')
#
#
#        Examples:
#
#               socks5  192.168.67.78   1080    lamer   secret
#       http    192.168.89.3    8080    justu   hidden
#       socks4  192.168.1.49    1080
#           http    192.168.39.93   8080    
#       
#
#       proxy types: http, socks4, socks5
#        ( auth types supported: "basic"-http  "user/pass"-socks )
#
[ProxyList]
# add proxy here ...
# meanwile
# defaults set to "tor"
socks5  127.0.0.1 3030

然后通过在前面添加proxychains4 来运行meteor,例如:

proxychains4 meteor add angularui:angular-ui-router

【讨论】:

    猜你喜欢
    • 2018-11-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-19
    • 1970-01-01
    • 2017-08-09
    • 2017-05-28
    相关资源
    最近更新 更多