fishliu
V2EX  ›  问与答

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

  •  
  •   fishliu · Aug 24, 2018 · 1695 views
    This topic created in 2821 days ago, the information mentioned may be changed or developed.
    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 replies    2018-09-19 11:27:01 +08:00
    ddzzhen
        1
    ddzzhen  
       Aug 25, 2018 via Android
    dns 配置多好,干嘛要用 nginx 配置
    fishliu
        2
    fishliu  
    OP
       Aug 26, 2018 via iPhone
    @ddzzhen dns 可以做到动态的么?就是说 a 是任意值,而且其实我这里是代理到内网,不知道是不是 nginx 的 proxy_pass 不支持变量
    ddzzhen
        3
    ddzzhen  
       Sep 19, 2018 via Android
    @fishliu 任意值有难度,单个的话可以用 dns 的 cname,内网需要穿透的,frp 了解下
    fishliu
        4
    fishliu  
    OP
       Sep 19, 2018
    @ddzzhen 嗯嗯,我这个问题已经解决了,上面的配置没有问题。哈哈
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1224 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 1291ms · UTC 17:45 · PVG 01:45 · LAX 10:45 · JFK 13:45
    ♥ Do have faith in what you're doing.