← Back

服务器 SSH 反向代理

Host aserver
    HostName ssh-cn-huabei1.ebcloud.com
    User root
    Port 38331
    RemoteForward 127.0.0.1:7890 127.0.0.1:7890
    ExitOnForwardFailure yes
  • 服务器所有 vscode 流量走本地的某个端口,这个端口会反向代理
export HTTP_PROXY=http://127.0.0.1:7890
export HTTPS_PROXY=http://127.0.0.1:7890
export ALL_PROXY=http://127.0.0.1:7890
export NO_PROXY=localhost,127.0.0.1,::1

在 vscode 的对应 aserver 插件中: open remote setting

{

    "http.useLocalProxyConfiguration": false,
    "http.proxy": "http://127.0.0.1:7890",
    "http.proxySupport": "override",
    "http.proxyStrictSSL": true,
    "http.noProxy": [
        "localhost",
        "127.0.0.1",
        "::1"
    ]
}

不确定下面是否有效

mkdir -p ~/.vscode-server
nano ~/.vscode-server/server-env-setup
#!/bin/sh

export HTTP_PROXY=http://127.0.0.1:7890
export HTTPS_PROXY=http://127.0.0.1:7890
export ALL_PROXY=http://127.0.0.1:7890
export NO_PROXY=localhost,127.0.0.1,::1