subdomain (other than www) added with redirect

Discussion in 'Installation/Configuration' started by slagroom, Sep 22, 2023.

  1. slagroom

    slagroom Member

    I have a customer that wants this scenario:
    domain.tld and www.domain.tld should both change to xyz.domain.tld in the browser-bar.
    Now, with nginx I had this working using
    Code:
    server {
        listen  443 ssl;
        listen  [::]:443 ssl;
        server_name domain.tld abc.domain.tld www.domain.tld;
    
        include /etc/nginx/yourTLSconfig;
    
        return 307 https://xyz.domain.tld$request_uri;
    }
    
    server {
        listen  443 ssl;
        listen  [::]:443 ssl;
        server_name xyz.domain.tld;
    
        include /etc/nginx/yourTLSconfig;
     
        root   /w/xyz.domain.tld
        index  index.html index.htm index.php;
        try_files  $uri $uri.htm $uri.html $uri/ $uri/index.html;
    
        etc.
    
    }
    
    but I can't seem to get that functional through the ISPconfig GUI. Is there a way to do this? I can create a site xyz.domain.tld and an alias domain.tld but that does not get redirected to from domain.tld or from *.domain.tld for that matter. I've been trying many options here. Am I missing something?
    I have some more situations where I'm probably better off using my own nginx.conf, but the problem is that I then want to include the correct links to the valid certificates, which I don't get working when the same sub.domain.tld are maintained by ispconfig. Anyone?
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    1) Create a website xyz.domain.tld in ISPConfig, auto subdomain must be set to none
    2) On the Redirect tab of the website, choose SEO redirect * => domain.tld
    3) Add an alias-domain domain.tld to website xyz.domain.tld, suto-subdomain must be set to 'www' in the alias domain.

    Just set this up here on a freshly installed ISPConfig Debian 12 NGINX system, works perfectly fine out of the box, and no manual config changes are required.
    2023-09-22 12_49_03-ISPConfig.png

    2023-09-22 12_49_16-ISPConfig.png

    2023-09-22 12_49_43-ISPConfig.png
    Let's Encrypt works out of the box for all domains in the above setup. There is no need to create any certs manually. All you have to do is to ensure that the domains (incl. subdomains) point to the server in DNS, then enable the Let's Encrypt and SSL checkbox in site settings and press save. That's all to get valid LE SSL certs for the whole domain setup incl. subdomains.
     
    slagroom and Benedict like this.
  3. slagroom

    slagroom Member

    til, man, you're my hero! Thanks. The thing I kept having wrong was the SEO Redirect, where setting the type to "No redirect" was a little counterintuitive, and then setting it to * => domain.tld did the trick. Sorry, it was the one option I'd not tried. Hope this thread may be useful for others too.
     
    Gwyneth Llewelyn likes this.
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    Ok, but how would you name an option that does no redirect if not "No redirect"?
     
  5. slagroom

    slagroom Member

    Well, strictly seen it *is* redirecting, just not in that tab, while it is called "Redirect".
     
  6. Aye, this always confused me as well o_O
    I guess that there are many usages of the word "redirect" here. One is a real, HTTP redirect, such as using code 301 and a Location header.
    Then there is the notion of "redirect" as "rewrite", in the sense used by nginx or Apache's rewriting rules. Strictly speaking those aren't quite "redirects" as well.
    And finally, there are DNS CNAMEs, all pointing to the "same" server/site, but that's just a conversion between address names and IP addresses. These would be more appropriately called "aliases" — and that's why the panel has these "Web Aliasdomain" concept — which most definitely are not "redirects".
    So... I guess it depends on what exactly you mean!
    Admittedly, I also have no idea what would be a "better" name. Maybe "DNS aliasing" followed by "(No redirect)" for the sake of letting existing users understand that this is not a new option, just an old one with a new name?
     

Share This Page