Nginx Directives to redirect *.domain.co to domain.co

Discussion in 'Server Operation' started by intrinsic, Aug 25, 2021.

  1. intrinsic

    intrinsic New Member

    Hello! Almost have the server perfectly configured but can't figure this one out.

    I'm trying to have the directives or vhost configuration to redirect misspelled subdomains to the main domain, e.g. xyz.domain.com to redirect to domain.com.

    However the misspelled domains instead give a https error page instead of redirecting. I do not have a wildcard SSL cert and it's currently using the built-in SSL feature. I've searched thoroughly, but cannot find the solution despite using many different tutorials.

    Under sites I have the following config:
    IPv4-Address: *
    Domain: domain.com
    Dependent sub- / aliasdomains: *.domain.com
    Auto-Subdomain: *.
    SSL: Checked
    Let's Encrypt SSL: Checked
    PHP: PHP-FPM

    Redirect
    Redirect Type: No flag
    Redirect Path: Blank
    SEO Redirect: *.domain.tdl => domain.tdl
    Rewrite Rules: Blank
    Rewrite HTTP to HTTPS: Checked

    Any help in solving this would be super appreciated!
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    There is no solution except getting a wildcard SSL cert in my opinion. A redirect always happens after SSL connect, so if SSL connect fails or requires to accept a wrong SSL cert, then you don't get redirected.
     
    intrinsic likes this.
  3. intrinsic

    intrinsic New Member

    Thank you, I will look into this and see if there is a method. Currently the Let's Encrypt SSL does not support wildcard SSL certs correct?
     
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    In ISPConfig that's not possible, as an LE wildcard cert requires DNS authentication and ISPConfig uses domain based authentication. But you can e.g. manually issue a LE cert using DNS auth and then replace the cert or symlink ispconfig created in the websites SSL folder with a symlink to that wildcard SSL cert.
     
  5. intrinsic

    intrinsic New Member

    This is a great method and I will look into implementing it as best I can. Should I fail, is there a paid service I can commission to have this setup? Greatly thank you for your insight.
     
  6. till

    till Super Moderator Staff Member ISPConfig Developer

    Th0m and intrinsic like this.
  7. intrinsic

    intrinsic New Member

    Th0m likes this.
  8. ahrasis

    ahrasis Well-Known Member HowtoForge Supporter

    To note, it will depend on the domain dns service that you use, your LE client and whether there is a proper working plugin for both your domain dns service and your LE client.

    A rough idea on how to obtain LE certs using certbot and cloudflare dns service is tipped in here: https://www.howtoforge.com/communit...via-certbot-dns-validation-in-acme-v02.79049/

    Of course professional services as suggested above will ease your work.
     

Share This Page