v2rayN icon indicating copy to clipboard operation
v2rayN copied to clipboard

[Feature request]: 如何在使用http代理上网的环境下使用

Open darkelf123 opened this issue 11 months ago • 12 comments

相关问题

目前所在的网络需要通过一个有账号和密码认证的http代理才能上网,v2rayn本身没有找到在哪里可以设置使用http代理,或者在哪里可以修改设置文件使用代理服务器?

描述你希望的解决方案

在哪里可以设置使用代理服务器

描述你所考虑的替代方案

No response

我确认已查询历史issues

  • [X] 是

darkelf123 avatar Mar 29 '24 05:03 darkelf123

可以考虑自定义配置

Lsyx-Good avatar Mar 29 '24 07:03 Lsyx-Good

可以考虑自定义配置

能否详细指导一下怎么操作?在issue里翻了半天没找到类似的情况

darkelf123 avatar Mar 29 '24 07:03 darkelf123

你是要通过http连接到国外网站,还是说直接上网呢,如果是不需要连接到国外的话,可以删除第一个出站,如果需要代理,换成你自己的协议detour字段保持不变,http出站换成自己server以及验证,以下为sing-box配置(主要关注出站部分

{
  "log": {
    "level": "info"
  },
  "dns": {
    "servers": [
      {
        "tag": "dns-remote",
        "address": "tls://8.8.8.8",
        "detour": "proxy"
      },
      {
        "tag": "dns-direct",
        "address": "h3://223.6.6.6/dns-query",
        "detour": "direct"
      },
      {
        "tag": "dns-block",
        "address": "rcode://success"
      }
    ],
    "rules": [
      {
        "geosite": "cn",
        "server": "dns-direct"
      },
      {
        "query_type": [
          "NIMLOC",
          "SRV"
        ],
        "server": "dns-block"
      },
      {
        "domain_suffix": ".lan",
        "server": "dns-block"
      }
    ],
    "independent_cache": true
  },
  "inbounds": [
    {
      "type": "mixed",
      "tag": "mixed-in",
      "listen": "127.0.0.1",
      "listen_port": 2080,
      "sniff": true
    }
  ],
  "outbounds": [
    {
      "type": "vmess",
      "tag": "proxy",
      "detour": "g-16433",
      "server": "",
      "server_port": 3389,
      "uuid": "9c050a86-d612-48f1-ec32-e73df08b7",
      "security": "auto",
      "transport": {
        "type": "http"
      }
    },
    {
      "type": "http",
      "tag": "g-16433",
      "server": "127.0.0.1",
      "server_port": 1080,
      "username": "user",
      "password": "pd"
    },
    {
      "type": "direct",
      "tag": "direct"
    },
    {
      "type": "direct",
      "tag": "bypass"
    },
    {
      "type": "block",
      "tag": "block"
    },
    {
      "type": "dns",
      "tag": "dns-out"
    }
  ],
  "route": {
    "rules": [
      {
        "protocol": "dns",
        "outbound": "dns-out"
      },
      {
        "domain_suffix": [
          "appcenter.ms",
          "app-measurement.com",
          "firebase.io",
          "crashlytics.com",
          "google-analytics.com",
          "media-match.com",
          "adclick.g.doublecklick.net",
          "www.googleadservices.com",
          "open.spotify.com",
          "pagead2.googlesyndication.com",
          "desktop.spotify.com",
          "googleads.g.doubleclick.net",
          "pubads.g.doubleclick.net",
          "audio2.spotify.com",
          "www.omaze.com",
          "omaze.com",
          "bounceexchange.com",
          "securepubads.g.doubleclick.net",
          "8.126.154.104.bc.googleusercontent.com",
          "104.154.126.8"
        ],
        "geosite": "category-ads-all",
        "outbound": "block"
      },
      {
        "geosite": "cn",
        "outbound": "bypass"
      },
      {
        "geoip": [
          "cn",
          "private"
        ],
        "outbound": "bypass"
      },
      {
        "network": "udp",
        "port": [
          135,
          137,
          138,
          139,
          5353
        ],
        "outbound": "block"
      },
      {
        "ip_cidr": [
          "224.0.0.0/3",
          "ff00::/8"
        ],
        "outbound": "block"
      },
      {
        "source_ip_cidr": [
          "224.0.0.0/3",
          "ff00::/8"
        ],
        "outbound": "block"
      }
    ]
  }
}

Lsyx-Good avatar Mar 29 '24 08:03 Lsyx-Good

你是要通过http连接到国外网站,还是说直接上网呢,如果是不需要连接到国外的话,可以删除第一个出站,如果需要代理,换成你自己的协议detour字段保持不变,http出站换成自己server以及验证,以下为sing-box配置(主要关注出站部分

{
  "log": {
    "level": "info"
  },
  "dns": {
    "servers": [
      {
        "tag": "dns-remote",
        "address": "tls://8.8.8.8",
        "detour": "proxy"
      },
      {
        "tag": "dns-direct",
        "address": "h3://223.6.6.6/dns-query",
        "detour": "direct"
      },
      {
        "tag": "dns-block",
        "address": "rcode://success"
      }
    ],
    "rules": [
      {
        "geosite": "cn",
        "server": "dns-direct"
      },
      {
        "query_type": [
          "NIMLOC",
          "SRV"
        ],
        "server": "dns-block"
      },
      {
        "domain_suffix": ".lan",
        "server": "dns-block"
      }
    ],
    "independent_cache": true
  },
  "inbounds": [
    {
      "type": "mixed",
      "tag": "mixed-in",
      "listen": "127.0.0.1",
      "listen_port": 2080,
      "sniff": true
    }
  ],
  "outbounds": [
    {
      "type": "vmess",
      "tag": "proxy",
      "detour": "g-16433",
      "server": "",
      "server_port": 3389,
      "uuid": "9c050a86-d612-48f1-ec32-e73df08b7",
      "security": "auto",
      "transport": {
        "type": "http"
      }
    },
    {
      "type": "http",
      "tag": "g-16433",
      "server": "127.0.0.1",
      "server_port": 1080,
      "username": "user",
      "password": "pd"
    },
    {
      "type": "direct",
      "tag": "direct"
    },
    {
      "type": "direct",
      "tag": "bypass"
    },
    {
      "type": "block",
      "tag": "block"
    },
    {
      "type": "dns",
      "tag": "dns-out"
    }
  ],
  "route": {
    "rules": [
      {
        "protocol": "dns",
        "outbound": "dns-out"
      },
      {
        "domain_suffix": [
          "appcenter.ms",
          "app-measurement.com",
          "firebase.io",
          "crashlytics.com",
          "google-analytics.com",
          "media-match.com",
          "adclick.g.doublecklick.net",
          "www.googleadservices.com",
          "open.spotify.com",
          "pagead2.googlesyndication.com",
          "desktop.spotify.com",
          "googleads.g.doubleclick.net",
          "pubads.g.doubleclick.net",
          "audio2.spotify.com",
          "www.omaze.com",
          "omaze.com",
          "bounceexchange.com",
          "securepubads.g.doubleclick.net",
          "8.126.154.104.bc.googleusercontent.com",
          "104.154.126.8"
        ],
        "geosite": "category-ads-all",
        "outbound": "block"
      },
      {
        "geosite": "cn",
        "outbound": "bypass"
      },
      {
        "geoip": [
          "cn",
          "private"
        ],
        "outbound": "bypass"
      },
      {
        "network": "udp",
        "port": [
          135,
          137,
          138,
          139,
          5353
        ],
        "outbound": "block"
      },
      {
        "ip_cidr": [
          "224.0.0.0/3",
          "ff00::/8"
        ],
        "outbound": "block"
      },
      {
        "source_ip_cidr": [
          "224.0.0.0/3",
          "ff00::/8"
        ],
        "outbound": "block"
      }
    ]
  }
}

目前就是直接打开v2rayn,无法更新机场的订阅地址,提示目标计算机积极拒绝。我希望能正常使用v2rayn,不用v2rayn的代理上网,而靠浏览器的switch插件来切换是否翻墙

darkelf123 avatar Mar 29 '24 08:03 darkelf123

我感觉我俩没在一个频道,您的意思是本身电脑可以正常上网是吧,然后你想在浏览器中通过插件进行切换是否需要代理?

Lsyx-Good avatar Mar 29 '24 08:03 Lsyx-Good

我感觉我俩没在一个频道,您的意思是本身电脑可以正常上网是吧,然后你想在浏览器中通过插件进行切换是否需要代理?

是的,电脑本身浏览器是通过公司的一个http代理服务器正常上网,直接用v2rayn是没办法更新订阅的。也没找到在哪里设置让v2rayn使用http代理服务器,目前我希望让v2rayN作为一个本地的sock5代理,浏览器通过插件来控制切换是使用公司的http代理访问国内网址还是通过v2rayn的socket5代理访问墙外网址

darkelf123 avatar Mar 29 '24 09:03 darkelf123

我感觉我俩没在一个频道,您的意思是本身电脑可以正常上网是吧,然后你想在浏览器中通过插件进行切换是否需要代理?

是的,电脑本身浏览器是通过公司的一个http代理服务器正常上网,直接用v2rayn是没办法更新订阅的。也没找到在哪里设置让v2rayn使用http代理服务器,目前我希望让v2rayN作为一个本地的sock5代理,浏览器通过插件来控制切换是使用公司的http代理访问国内网址还是通过v2rayn的socket5代理访问墙外网址

这样说的话,你在v2rayn自定义一个http配置不就好了,看你用什么内核,就到相关内核的http的配置进行配置

Lsyx-Good avatar Mar 29 '24 09:03 Lsyx-Good

我感觉我俩没在一个频道,您的意思是本身电脑可以正常上网是吧,然后你想在浏览器中通过插件进行切换是否需要代理?

是的,电脑本身浏览器是通过公司的一个http代理服务器正常上网,直接用v2rayn是没办法更新订阅的。也没找到在哪里设置让v2rayn使用http代理服务器,目前我希望让v2rayN作为一个本地的sock5代理,浏览器通过插件来控制切换是使用公司的http代理访问国内网址还是通过v2rayn的socket5代理访问墙外网址

这样说的话,你在v2rayn自定义一个http配置不就好了,看你用什么内核,就到相关内核的http的配置进行配置

我使用的是v2rayN-With-Core-SelfContained,用的xray的内核,麻烦请指导一下在哪里配置?没找到设置文件所在的路径。

darkelf123 avatar Mar 29 '24 09:03 darkelf123

先用自定义配置实现 就是普通节点前置一个http代理, 你可以先把正常的节点导出成客户端配置,然后把前置http加到outbounds中

2dust avatar Mar 29 '24 10:03 2dust

先用自定义配置实现 就是普通节点前置一个http代理, 你可以先把正常的节点导出成客户端配置,然后把前置http加到outbounds中

我在导出的配置中修改加入了http代理,不知道对不对?在63到70行:{ "policy": { "system": { "statsOutboundUplink": true, "statsOutboundDownlink": true } }, "log": { "access": "", "error": "", "loglevel": "warning" }, "inbounds": [ { "tag": "socks", "port": 10808, "listen": "127.0.0.1", "protocol": "socks", "sniffing": { "enabled": true, "destOverride": [ "http", "tls" ] }, "settings": { "auth": "noauth", "udp": true, "allowTransparent": false } }, { "tag": "http", "port": 10809, "listen": "127.0.0.1", "protocol": "http", "sniffing": { "enabled": true, "destOverride": [ "http", "tls" ] }, "settings": { "auth": "noauth", "udp": true, "allowTransparent": false } }, { "tag": "api", "port": 54370, "listen": "127.0.0.1", "protocol": "dokodemo-door", "settings": { "udp": false, "address": "127.0.0.1", "allowTransparent": false } } ], "outbounds": [ { "type": "http", "tag": "g-16433", "server": "10.51.1.230", "server_port": 8008, "username": "user", "password": "password" }, { "tag": "proxy", "protocol": "vmess", "settings": { "vnext": [ { "address": "example.com", "port": 555, "users": [ { "id": "example", "alterId": 0, "email": "[email protected]", "security": "auto" } ] } ] }, "streamSettings": { "network": "tcp" }, "mux": { "enabled": true, "concurrency": 8 } }, { "tag": "direct", "protocol": "freedom", "settings": {} }, { "tag": "block", "protocol": "blackhole", "settings": { "response": { "type": "http" } } } ], "stats": {}, "api": { "tag": "api", "services": [ "StatsService" ] }, "dns": { "servers": [ "8.8.4.4", "8.8.8.8" ] }, "routing": { "domainStrategy": "AsIs", "rules": [ { "type": "field", "inboundTag": [ "api" ], "outboundTag": "api", "enabled": true }, { "type": "field", "outboundTag": "proxy", "domain": [ "geosite:google" ], "enabled": true }, { "type": "field", "outboundTag": "direct", "domain": [ "domain:example-example.com", "domain:example-example2.com" ], "enabled": true }, { "type": "field", "outboundTag": "block", "domain": [ "geosite:category-ads-all" ], "enabled": true } ] } }

darkelf123 avatar Mar 29 '24 10:03 darkelf123

大概这样,你可以去文档里面找 dialerProxy

{
    "policy": {
        "system": {
            "statsOutboundUplink": true,
            "statsOutboundDownlink": true
        }
    },
    "log": {
        "access": "",
        "error": "",
        "loglevel": "warning"
    },
    "inbounds": [
        {
            "tag": "socks",
            "port": 10808,
            "listen": "127.0.0.1",
            "protocol": "socks",
            "sniffing": {
                "enabled": true,
                "destOverride": [
                    "http",
                    "tls"
                ]
            },
            "settings": {
                "auth": "noauth",
                "udp": true,
                "allowTransparent": false
            }
        },
        {
            "tag": "http",
            "port": 10809,
            "listen": "127.0.0.1",
            "protocol": "http",
            "sniffing": {
                "enabled": true,
                "destOverride": [
                    "http",
                    "tls"
                ]
            },
            "settings": {
                "auth": "noauth",
                "udp": true,
                "allowTransparent": false
            }
        },
        {
            "tag": "api",
            "port": 54370,
            "listen": "127.0.0.1",
            "protocol": "dokodemo-door",
            "settings": {
                "udp": false,
                "address": "127.0.0.1",
                "allowTransparent": false
            }
        }
    ],
    "outbounds": [
      
        {
            "tag": "proxy",
            "protocol": "vmess",
            "settings": {
                "vnext": [
                    {
                        "address": "example.com",
                        "port": 555,
                        "users": [
                            {
                                "id": "example",
                                "alterId": 0,
                                "email": "[email protected]",
                                "security": "auto"
                            }
                        ]
                    }
                ]
            },
            "streamSettings": {
                "network": "tcp",
                "sockopt": {
                    "dialerProxy": "g-16433"  
                }
            },
            "mux": {
                "enabled": true,
                "concurrency": 8
            }
        },
        {
            "type": "http",
            "tag": "g-16433",
            "server": "10.51.1.230",
            "server_port": 8008,
            "username": "user",
            "password": "password"
        },
        {
            "tag": "direct",
            "protocol": "freedom",
            "settings": {}
        },
        {
            "tag": "block",
            "protocol": "blackhole",
            "settings": {
                "response": {
                    "type": "http"
                }
            }
        }
    ],
    "stats": {},
    "api": {
        "tag": "api",
        "services": [
            "StatsService"
        ]
    },
    "dns": {
        "servers": [
            "8.8.4.4",
            "8.8.8.8"
        ]
    },
    "routing": {
        "domainStrategy": "AsIs",
        "rules": [
            {
                "type": "field",
                "inboundTag": [
                    "api"
                ],
                "outboundTag": "api",
                "enabled": true
            },
            {
                "type": "field",
                "outboundTag": "proxy",
                "domain": [
                    "geosite:google"
                ],
                "enabled": true
            },
            {
                "type": "field",
                "outboundTag": "direct",
                "domain": [
                    "domain:example-example.com",
                    "domain:example-example2.com"
                ],
                "enabled": true
            },
            {
                "type": "field",
                "outboundTag": "block",
                "domain": [
                    "geosite:category-ads-all"
                ],
                "enabled": true
            }
        ]
    }
}

2dust avatar Mar 29 '24 10:03 2dust

谢谢指导,我去研究一下

darkelf123 avatar Mar 29 '24 10:03 darkelf123

不是订阅的,自建的不能用吗?

Mapaler avatar Apr 14 '24 19:04 Mapaler

不是订阅的,自建的不能用吗?

自建的加入到一个分组中即可

2dust avatar Apr 14 '24 23:04 2dust