How to Force a Domain to Use HTTPS on a Directadmin Server with nginx

By | March 20, 2018

If you need to have only https access to a domain, you’ll have to set up proper redirection. Since .htaccess files are not working in case you have selected nginx as your web server, you’ll have to adjust your configuration files. Let me show you how to do this in Directadmin, without even touching any files. If you need a solution for Apache – you’ll just need to add a simple .htaccess file as user – check here.

First open Directadmin as admin, choose Admin Level and scroll down for Extra Features -> Custom HTTPD Configurations

directadmin custom httpd

If you need the direct address, here it is:

https://yourdomain.com:2222/CMD_CUSTOM_HTTPD

Then search for your domain name and click it.

Click Additional Custom Tokens

Then choose CUSTOM4

And insert the following code into this section:

|*if SSL_TEMPLATE="0"|
       return 301 https://$host$request_uri;
|*endif|

Click Save. Now it’s time to restart nginx to enable these changes.

Go to Service Monitor:

https://yourdomain.com:2222/CMD_SHOW_SERVICES

Click Restart for nginx.

That’s it! You should now have your site redirected to HTTPS, of course, if you have set an SSL access as user.

16 thoughts on “How to Force a Domain to Use HTTPS on a Directadmin Server with nginx

  1. Sang

    I see You’re really a excellent webmaster. This site loading speed is incredible.
    It kind of feels that you are doing any distinctive trick.
    In addition, the contents are masterwork. you’ve done a magnificent activity in this subject!

    Similar here: najlepszy sklep and
    also here: Najlepszy sklep

    Reply
  2. sklep online

    Hey there! Do you know if they make any plugins
    to assist with Search Engine Optimization? I’m trying to get my blog to rank
    for some targeted keywords but I’m not seeing very good success.
    If you know of any please share. Thanks! You can read similar article here: Najlepszy sklep

    Reply
  3. najlepszy sklep

    Good day! Do you know if they make any plugins to help
    with Search Engine Optimization? I’m trying
    to get my blog to rank for some targeted keywords but I’m not seeing very good gains.
    If you know of any please share. Cheers! You can read similar text here: E-commerce

    Reply
  4. sklep

    Hello there! Do you know if they make any plugins to
    help with Search Engine Optimization? I’m trying to get my blog to rank for
    some targeted keywords but I’m not seeing very good gains.
    If you know of any please share. Many thanks!
    You can read similar text here: Dobry sklep

    Reply
  5. dobry sklep

    Hey there! Do you know if they make any plugins to assist with Search Engine Optimization? I’m trying to get my blog to rank for some targeted
    keywords but I’m not seeing very good results. If you know
    of any please share. Thank you! You can read similar art here: Ecommerce

    Reply
  6. Link Building

    Hello! Do you know if they make any plugins to help with SEO?
    I’m trying to get my site to rank for some targeted keywords but I’m not seeing very good gains.
    If you know of any please share. Thanks! You can read similar text here:
    Backlink Portfolio

    Reply
  7. Scrapebox List

    Hey! Do you know if they make any plugins to help with SEO?
    I’m trying to get my website to rank for some targeted keywords but I’m not seeing very good results.
    If you know of any please share. Appreciate it!
    You can read similar text here: GSA Verified List

    Reply
  8. Ramonita79

    Wow, fantastic weblog layout!
    How lengthy have you been blogging for? you made
    running a blog look easy. The full look of your site is fantastic, as well as the
    content material! You can see similar here prev next and those was wrote by
    Trevor69.

    Reply
  9. Maxie86

    Wow, fantastic weblog layout!
    How long have you ever been running a blog for?

    you make blogging glance easy. The full glance of your website is great, let alone the content
    material! I saw similar here prev next and that was wrote by Avery65.

    Reply
  10. Sandy87

    Wow, marvelous blog layout!
    How long have you ever been running a blog for?
    you made running a blog look easy. The full look
    of your site is wonderful, let alone the content material!

    You can read similar here prev next and those was wrote by
    Rene82.

    Reply
  11. Fiona74

    Wow, marvelous blog structure!
    How long have you ever been blogging for? you make running a blog glance easy.
    The overall glance of your web site is excellent, as smartly as the content material!
    You can see similar here prev next and those was wrote by Dwight94.

    Reply
  12. Tanja64

    Wow, amazing blog layout!

    How long have you ever been blogging for? you made running a
    blog glance easy. The total look of your web site is magnificent, let alone the content!

    You can read similar here prev next and
    those was wrote by Modesto02.

    Reply
  13. ChristenBun

    Wow, superb blog structure!
    How lengthy have you been blogging for? you make running
    a blog glance easy. The total look of your web site is wonderful,
    as well as the content! You can see similar here prev
    next and that
    was wrote by Theo83.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *