当前位置: 首页 > article >正文

Mobaxterm: Local port forwarding Remote port forwarding

文章目录

  • Remote port forwarding
  • Local port forwarding
  • Appendix: Deploy clash in docker

Remote port forwarding

If you want to share the proxy on your local machine with the remote server, use Remote port forwarding.

Consider this scenario: There is no proxy configured in the remote server, you may fail to install software using the apt command, download code repositories using git clone, or access docker hub due to network problems, but in your laptop you have installed Clash for Windows, then you can share it with the remote server without installing clash on the server.

Follow these steps:

  1. In Mobaxterm, open Tools->MobaSSHTunnel(port forwarding)
    在这里插入图片描述
  2. Open New SSH tunnel
    在这里插入图片描述
  3. Set the port forwarding parameters
  • <Local server>: 127.0.0.1
  • <Local port>: 7890 (the port of your clash)
  • <SSH server>: remote server’s ip (for example 10.xxx.xxx.xxx)
  • <SSH login>: your username on the remote server
  • <SSH port>: 22
  • <Forwarded port>: 7890 (if you want to use port 7890 of the server for proxy)
    在这里插入图片描述
    Then Save and click Start button to enable forwarding.
  1. In the server, set the proxy parameters
  • proxy for bash
export http_proxy="http://127.0.0.1:7890" && export https_proxy="http://127.0.0.1:7890"
  • proxy for apt
sudo vim /etc/apt/apt.conf.d/proxy.conf

In proxy.conf, add these contents

Acquire {
  http::proxy "http://127.0.0.1:7890";
  https::proxy "http://127.0.0.1:7890";
}
  • proxy for docker daemon
sudo vim /etc/systemd/system/docker.service.d/proxy.conf

In proxy.conf, add these contents

[Service]
Environment="HTTP_PROXY=127.0.0.1:7890"
Environment="HTTPS_PROXY=127.0.0.1:7890"
Environment="NO_PROXY=localhost,127.0.0.1,.example.com"
sudo systemctl daemon-reload && sudo systemctl restart docker
  • proxy for docker container
vim ~/.docker/config.json

In config.json, add these contents and replace 192.168.xxx.xxx with the real IP address of the remote server (do not use 127.0.0.1)

{
 "proxies":
 {
   "default":
   {
     "httpProxy": "http://192.168.xxx.xxx:7890/",
     "httpsProxy": "http://192.168.xxx.xxx:7890/",
     "noProxy": "localhost,127.0.0.1"
   }
 }
}
  1. Now you have completed all the settings. Next time if you want to share the proxy when you connect to the same server, just click Start button to enable forwarding.

Local port forwarding

If you have installed clash on your server and you want to manage it through the web UI, use Local port forwarding.

Clash provides a web UI (https://clash.razord.top/#/proxies). After setting external-controller in ~/.config/clash/config.yaml, users can use the web UI to manage Clash through the specified port.

For example, in config.yaml external-controller: 0.0.0.0:9090, you can access the web UI through 10.xxx.xxx.xxx:9090, but if the server firewall does not open port 9090, you can use Local port forwarding to map port 9090 to other ports such as 9090 or 9091 on the local machine, and then access the local port.

在这里插入图片描述

  • <Remote server>: 127.0.0.1
  • <Remote port>: 9090 (the port of external-controller)
  • <SSH server>: remote server’s ip (for example 10.xxx.xxx.xxx)
  • <SSH login>: your username on the remote server
  • <SSH port>: 22
  • <Forwarded port>: 9091 (if you want to use port 9091 of your local machine to access the clash Web UI in the server)

Appendix: Deploy clash in docker

docker-compose.yaml

services:
  clash:
    image: dreamacro/clash-premium:2023.08.17
    restart: always
    volumes:
      - ./config.yaml:/root/.config/clash/config.yaml:ro
      # - ./yacd-gh-pages:/root/.config/clash/ui:rwx # 仪表盘 Volume 映射
    ports:
      - "7890:7890"
      - "7891:7891"
      - "9090:9090" # 外部控制 (RESTful API)
    cap_add:
      - NET_ADMIN
    devices:
      - /dev/net/tun
    network_mode: "host"

You can copy config.yaml from your computer.

  • Start
docker compose up -d
  • Stop
docker compose down
  • View logs
docker compose logs

http://www.kler.cn/a/554232.html

相关文章:

  • 解码 NLP:从萌芽到蓬勃的技术蜕变之旅
  • Docker 镜像加速器配置指南
  • 大量请求,数据库连接不足,会导致什么问题,最大连接数一般设置多大
  • pptx文档提取信息
  • UDP通信开发
  • 深研究:与Dify建立研究自动化应用
  • Rust编程语言入门教程(四)猜数游戏:一次猜测
  • Git环境搭建指南
  • WEB安全--SQL注入--POST传参注入、SQL头部注入
  • vue2自定义useVModel函数
  • 【MySQL】ERROR 1524 (HY000): Plugin ‘mysql_native_password‘ is not loaded 解决方法
  • Docker 部署 Dify:轻松集成 Ollama 和 DeepSeek
  • 第1章大型互联网公司的基础架构——1.7 MySQL
  • RTSP协议讲解及漏洞挖掘
  • 西电B测-计算机网络综合实验(含验收问题)
  • 分享8款AI生成PPT的工具!含测评
  • 面试题之手写call,apply,bind
  • 【数据迁移】Sqlserver 迁移 Postgresql 详解 CSV+COPY 详细图文教程(实战踩坑优化案例)
  • 无人机热成像与AI跟踪技术:全天候智能应用的未来!
  • 运用先进的智能算法和优化模型,进行科学合理调度的智慧园区开源了