how to force TLS/SSL in the Wordpress one-click app

Posted March 13, 2020 2.7k views
WordPressDigitalOcean 1-Click Apps MarketplaceUbuntu 18.04

Ubuntu 18.04, no virtual server setup, single website only, following directions from marketplace, closed port 80, but there was no instructions on how to force all web traffic to use https.

Any help would be appreciated.

Thank you.

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.

Submit an Answer
2 answers

Hi @johnnyrook,

I won’t recommend closing port 80 just redirecting all traffic from HTTP to HTTPS.

There are a few ways to do so.

  1. Redirect to https using .htaccess
  2. Redirect to https using a WordPress plugin
  3. Redirect to https via Nginx

Redirect to https using .htaccess

In your website’s .htaccess you can add the following code

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

It should be enough to help you with the redirection.

Redirect to https using a WordPress plugin

Using a WordPress can be really easy, it will both help you redirect to HTTPS and solve the potential problem of a Mixed Content. Here are a couple of plugins you can use

Redirect to https via Nginx

If you are using Nginx, you can add the following server block

server {
listen 80;
return 301$request_uri;

The above should be added in your website’s Nginx vhost file.

Additionally, please make sure to change with your domain name.


  • Hi there @johnnyrook,

    Yes indeed as @KDSys mentioned, port 80 should remain open in all cases otherwise if anyone visits your site via http:// they would get a timeout. You instead need a 301 redirect to forward the traffic from port 80 to 443.

    In addition to what @KDSys recommended, if you don’t already have the SSL certificate installed, in order to obtain an SSL certificate, you could run the following:

    certbot --apache

    Then you would be prompted with a text menu where you could follow the steps and provide the necessary input. At the end you would be asked if you would like to setup a redirect from HTTP to HTTPS.

    Hope that this helps!

  • thank you all for the suggestions and help.

    with your help, the issue has been resolved

    thanks again