V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
fishliu
V2EX  ›  问与答

nginx 配置求助,我想实现类似访问{a}.xxx.yyy.com 转发到{a}.somequery.somequery.com,配置在正文,访问 502 呢,不知道问题出在哪儿

  •  
  •   fishliu · 2018-08-24 17:51:16 +08:00 · 993 次点击
    这是一个创建于 2064 天前的主题,其中的信息可能已经有所发展或是发生改变。
    server
        {
            listen 80;
            #listen [::]:80;
            server_name ~^(?<domain>.+)\.xxx\.yyy\.com$;
            location / {
                proxy_redirect          off;
                # proxy_set_header      Accept-Encoding gzip;
                proxy_set_header   Host             $domain.somequery.somequery.com;
                proxy_set_header   X-Real-IP        $remote_addr;
                proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
                proxy_pass          http://$domain.somequery.somequery.com;
            }
    
           
            access_log  /home/wwwlogs/xxx.yyy.com.log;
        }
    

    大佬们看看,先行谢过

    4 条回复    2018-09-19 11:27:01 +08:00
    ddzzhen
        1
    ddzzhen  
       2018-08-25 02:47:25 +08:00 via Android
    dns 配置多好,干嘛要用 nginx 配置
    fishliu
        2
    fishliu  
    OP
       2018-08-26 01:01:12 +08:00 via iPhone
    @ddzzhen dns 可以做到动态的么?就是说 a 是任意值,而且其实我这里是代理到内网,不知道是不是 nginx 的 proxy_pass 不支持变量
    ddzzhen
        3
    ddzzhen  
       2018-09-19 11:12:21 +08:00 via Android
    @fishliu 任意值有难度,单个的话可以用 dns 的 cname,内网需要穿透的,frp 了解下
    fishliu
        4
    fishliu  
    OP
       2018-09-19 11:27:01 +08:00
    @ddzzhen 嗯嗯,我这个问题已经解决了,上面的配置没有问题。哈哈
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3645 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 38ms · UTC 04:28 · PVG 12:28 · LAX 21:28 · JFK 00:28
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.