V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
guoguobaba
V2EX  ›  Linux

这个代理怎么实现?

  •  
  •   guoguobaba · 244 天前 · 2107 次点击
    这是一个创建于 244 天前的主题,其中的信息可能已经有所发展或是发生改变。

    客户现场 https 代理,比如 192.168.10.100:8080 ,需要把访问的主机的 hostname 映射到 192.168.10.100 ,比如 https://www.baidu.com ,需要在/etc/hosts 里加上 192.168.10.100 www.baidu.com

    然后就可以通过访问 http://www.baidu.com:8080/xxx 访问百度了

    如果单个域名这么干,我想到的是 nginx 反向代理

    '''

    server { listen 8080; server_name www.baidu.com;

        location /{
                proxy_pass https://www.baidu.com
        }
    

    }

    '''

    但是怎么实现通用的域名这么干呢?

    13 条回复    2023-08-29 10:41:35 +08:00
    Smilencer
        1
    Smilencer  
       244 天前
    完全没看懂你在表达啥
    AoEiuV020JP
        2
    AoEiuV020JP  
       244 天前
    感觉这操作有问题啊,如果要访问 baidu 的 8080 端口和 80 端口,怎么分别表示这两种情况?
    Tink
        3
    Tink  
       244 天前
    不是 sni 代理?
    zzznow
        4
    zzznow  
       244 天前
    www.baidu.com 改成*可以吗?
    zhangxudong
        5
    zhangxudong  
       244 天前
    感觉你需要的是正向代理
    pagxir
        6
    pagxir  
       243 天前 via Android
    proxy_pass https://www.baidu.com 可以改成引用的方式的比如 proxy_pass https://$1
    ShuA1
        7
    ShuA1  
       243 天前
    给 nginx 配置 dns ,server 统配符*
    aqua02
        8
    aqua02  
       243 天前 via Android
    server_name _
    dzdh
        9
    dzdh  
       243 天前
    sni ?
    tedding
        12
    tedding  
       243 天前
    @AoEiuV020JP 歪个楼 你这个头像啥时候的啊。。。
    AoEiuV020JP
        13
    AoEiuV020JP  
       243 天前
    @tedding #12 咋,你认识?刚上大学军训时宿舍里自拍的,好些年了吧,
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5456 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 08:44 · PVG 16:44 · LAX 01:44 · JFK 04:44
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.