Report this

What is the reason for this report?

SSL but no HTTPS on subdomain

Posted on May 16, 2020

Hello. I have set up a droplet with Nginx, running both a Pleroma social media server at social.url.com and a Wordpress blog at blog.url.com. I have obtained SSL certificates for all subdomains via Let’s Encrypt / Certbot, and they are working - I can go to https://blog.url.com just fine, but when I go to blog.url.com it loads over HTTP instead of HTTPS.

Here is the current server block for the Wordpress blog:

server {
    listen 80;
    server_name blog.url.com;
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl;
    ssl_session_timeout 5m;
    ssl_certificate     /etc/letsencrypt/live/blog.url.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/blog.url.com/privkey.pem;
    server_name         blog.ulr.com;
    root                /var/www/html/blog.url.com/public_html;
    index               index.php;

    location / {
      try_files $uri $uri/ =404;
    }

    location ~* \.php$ {
      fastcgi_pass unix:/run/php/php7.4-fpm.sock;
      include          fastcgi_params;
      fastcgi_param    SCRIPT_FILENAME    $document_root$fastcgi_script_name;
      fastcgi_param    SCRIPT_NAME        $fastcgi_script_name;
    }
}

HTTPS is working just fine on the Pleroma server at social.url.com.

What have I got wrong here? Like I said, HTTPS works if you force it in the browser, but if you just type blog.url.com it brings it up unencrypted by default.

Thank you for your time. I assure you, I have Googled myself blind finding half-answers and things completely unrelated to my situation. Nothing so far has worked.



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi there @barrenmetropolis,

What I could suggest is changing the server block for port 80 to:

server {
    if ($host = blog.url.com) {
        return 301 https://$host$request_uri;
    }

    listen 80;
    server_name blog.url.com;
    return 404;
}

This is what I usually use for such redirects.

Let me know how it goes!

Regards, Bobby

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.