V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
NGINX
NGINX Trac
3rd Party Modules
Security Advisories
CHANGES
OpenResty
ngx_lua
Tengine
在线学习资源
NGINX 开发从入门到精通
NGINX Modules
ngx_echo
jsjcjsjc
V2EX  ›  NGINX

关于 nginx 域名跳转的问题

  •  
  •   jsjcjsjc · 2019-08-17 21:38:08 +08:00 · 2878 次点击
    这是一个创建于 1932 天前的主题,其中的信息可能已经有所发展或是发生改变。

    情况是这样的,无论输入下列哪种情况,都希望跳转到 bcd456.com
    应该怎么写啊
    http://www.abc123.com
    http://123213.abc123.com
    http://abc123.com
    http://www.abc123.com/3232d
    http://123213.abc123.com/3232d
    http://abc123.com/3232d
    https://www.abc123.com
    https://123213.abc123.com
    https://abc123.com
    https://www.abc123.com/3232d
    https://123213.abc123.com/3232d
    https://abc123.com/3232d

    原来是这样配置的,但是这两个不行
    https://www.abc123.com
    https://123213.abc123.com
    https://www.abc123.com/3232d
    https://123213.abc123.com/3232d

    server
        {
            listen 80;
            server_name abc123.com www.abc123.com *.abc123.com;
            location / {
                  rewrite ^/(.*) https://abc123.com/$1 permanent;
            }
        }
    
    server {
      server_name abc123.com;
      listen 443;
    
      ssl on;
      ssl_certificate /etc/letsencrypt/m/fullchain.pem;
      ssl_certificate_key /etc/letsencryp/privkey.pem;
    
      return 301  http://bcd456.com$request_uri;
    }server
        {
            listen 80;
            server_name abc123.com www.abc123.com *.abc123.com;
            location / {
                  rewrite ^/(.*) https://abc123.com/$1 permanent;
            }
        }
    
    server {
      server_name abc123.com;
      listen 443;
    
      ssl on;
      ssl_certificate /etc/letsencrypt/m/fullchain.pem;
      ssl_certificate_key /etc/letsencryp/privkey.pem;
    
      return 301  http://bcd456.com$request_uri;
    }
    

    后来申请了泛域名配置改成如下,发现只有这 4 个可以跳转
    https://www.abc123.com
    https://123213.abc123.com
    https://www.abc123.com/3232d
    https://123213.abc123.com/3232d

    server
        {
            listen 80;
            server_name abc123.com www.abc123.com *.abc123.com;
            location / {
                  rewrite ^/(.*) https://abc123.com/$1 permanent;
            }
        }
    
    
    server {
      server_name abc123.com www.abc123.com *.abc123.com;
      listen 443;
    
      ssl on;
      ssl_certificate /etc/letsencrypt/m/fullchain.pem;
      ssl_certificate_key /etc/letsencryp/privkey.pem;
    
      return 301  http://bcd456.com$request_uri;
    }
    
    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1021 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 21ms · UTC 19:52 · PVG 03:52 · LAX 11:52 · JFK 14:52
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.