Avatar

Organizations

3 results for Proxy
  • 使用snap 的过程中经常遇到无法链接的情况。

    $ sudo snap install code --classic
    error: unable to contact snap store
    

    这是因为SnapCraft将软件包放在自己的海外服务器上,因为众所周知的原因,访问速度异常缓慢,不加代理的情况下,基本无法使用。

    Linux上的一些应用程序会通过读取环境变量 http_proxy 和 https_proxy 来应用代理服务器设置,典型的有Chrome。

    然而,Snap比较特别,它不会从环境变量中上述环境变量中读取代理服务器设置,因此直接使用

    export http_proxy=[代理服务器地址]
    export https_proxy=[代理服务器地址]
    

    是不起作用的。

    网上有一些修改配置文件的方法,个人觉得很麻烦,也容易出错,所以选了最简单可靠的命令行模式。

    1. 设置命令

    $ sudo snap set system proxy.https="http://代理服务器地址:代理端口"
    $ sudo snap set system proxy.http="http://代理服务器地址:代理端口"
    

    参考文档

    proxy Snap Created Fri, 19 Jan 2024 13:15:15 +0800
  • 1. 使用手册

    看完这3篇足以把服务建起来,非常方便

    2. 服务端安装配置

    可直接使用 Docker 的配置进行

    3. 客户端下载、 安装、运行

    原本也想使用Docker镜像,但发现kvm之间通过Docker通信好像有问题,所幸在宿主机上可以直接使用release文件。 【注意:每次添加新的客户端,要同步更新服务端的端口配置

    3.1. 下载

    官网下载地址注意:s, c两端使用的版本号要相同

    $ cd ~
    # 下载安装软件
    $ yum install wget tar git
    # 下载 frp
    $ wget -c https://github.com/fatedier/frp/releases/download/v0.34.3/frp_0.34.3_linux_amd64.tar.gz
    $ tar -axvf frp_0.34.3_linux_amd64.tar.gz
    $ rm -rf frp_0.34.3_linux_amd64.tar.gz
    # 下载 frp 配置
    $ git clone https://github.com/Cuile/frp.git
    

    3.2. 安装

    # 此处只能使用硬链接,使用软链接会导致无法启动服务
    # 安装配置文件
    $ mkdir /etc/frp
    $ ln -b ~/frp/conf/frpc-pve.ini /etc/frp/frpc.ini
    # 安装运行文件
    $ ln -b ~/frp_0.34.3_linux_amd64/frpc /usr/bin/frpc
    # 安装服务
    $ ln -b ~/frp_0.34.3_linux_amd64/systemd/frpc.service /lib/systemd/system/frpc.service
    

    3.3. 运行

    $ systemctl enable frpc.service           ##设定指定服务开机开启
    $ systemctl disable frpc.service          ##设定指定服务开机关闭
    
    $ systemctl start frpc.service
    $ systemctl stop frpc.service
    $ systemctl restart frpc.service
    
    $ systemctl status frpc.service
    $ systemctl list-units | grep frpc
    

    3.4. 更新

    通过 git 更新 frpc 的配置后,要重新链接配置文件

    frp proxy linux Created Wed, 28 Dec 2022 17:15:15 +0800
  • 本文记录OpenWrt设置透明代理的步骤及原理。

    1. 系统环境

    • 硬件环境:Windows 10 Hyper-V虚拟机,单核处理器,256M内存
    • 固件版本:OpenWrt 19.07.6 r11278-8055e38794 / LuCI openwrt-19.07 branch git-21.101.59933-c56d9f2
    • shadowsocks-libev:3.3.5
    • luci-app-shadowsocks:2.0.2
    • v2ray-plugin:4.37.3-20210413
    • ChinaDNS:1.3.3
    • luci-app-chinadns:1.6.2
    • https-dns-proxy:2021-01-17-5
    • luci-app-https-dns-proxy:git-21.062.76689-a607f9c-1
    • luci-i18n-https-dns-proxy-zh-cn:git-21.062.76689-a607f9c-1

    2. 运行流程

    透明代理的运行原理主要由DNS访问流程IP访问流程两部分组成组成

    2.1 DNS访问流程

    flowchart LR
        lh((localhost));
        dm(Dnsmasq);
        cd(ChinaDNS);
        hdp(https-dns-proxy);
        ss(Shadowsocks);
        fd(国外DNS);
        dd(国内DNS);
    
        lh -- 1 udp:53 --> dm;
        dm -- 2 udp:5555 --> cd;
        cd -- 3.1 udp:5353--> hdp;
        cd -- 3.2 udp --> dd;
        hdp -- 4 tcp --> ss;
        ss -- 5 tcp --> fd;
    
        fd -. 6 .-> ss;
        ss -. 7 .-> hdp;
        hdp -. 8.1 .-> cd;
        dd -. 8.2 .-> cd;
        cd -. 9 缓存 .-> dm;
        dm -. 10 IP地址 .-> lh;
    

    2.2 IP访问流程

    flowchart LR
        fs(国外服务器);
        ds(国内服务器);
        lh((localhost));
        route{chinadns_chnroute.txt};
        ss(Shadowsocks);
    
        lh -- 1 --> route;
        route -- 2.1 国内IP --> ds;
        route -- 2.2 国外IP --> ss;
        ss -- 3 加密访问 --> fs;
    
        fs -. 4 返回加密数据 .-> ss;
        ds -. 5.1 返回数据 .-> lh;
        ss -. 5.2 返回解密数据 .-> lh;
    

    3. 配置

    3.1 Shadowsocks-libev + v2ray-plugin

    • 服务器管理-编辑服务器-插件参数:一定要加上"loglevel=none",如果不加v2ray-plugin插件几分钟就会被系统杀死
    • 访问控制-被忽略IP列表:/etc/chinadns_chnroute.txt

    3.2 https-dns-proxy

    由于使用了v2ray-plugin 插件,导致Shadowsocks不再支持UDP包,所以使用TCP的方式查询DNS

    v2ray proxy ShadowSocks OpenWRT Created Mon, 07 Feb 2022 13:37:19 +0800