Hi, I install my wordpress site on an ubuntu 18.04 droplet and after posting a few articles I proceed to install lestencrypt.
My https site works fine, my problem is when trying to enter with http it does not redirect.
This is the .httacces file from my site:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
And my 80 VirtualHost at /etc/apache2/sites-available (instead of example is my domain):
<VirtualHost *:80>
ServerAdmin webmaster@example.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/onemoreshot
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/onemoreshot/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
RewriteEngine on
RewriteCond %{SERVER_NAME} =example.com [OR]
RewriteCond %{SERVER_NAME} =www.example.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
And my 443 VirtualHost at /etc/apache2/sites-available (instead of example is my domain)
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin webmaster@example.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/example/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
</VirtualHost>
</IfModule>
I tried both, redirection by .httaccess and by VirtualHost. I’m using google domain.
Thanks in advance
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!
Hi there @juanmorschrott,
As you’re using WordPress for your website, it may be much easier to use a WordPress plugin to handle the HTTP->HTTPS rewrites instead of setting up yourself with rewrite rules.
I would suggest a plugin such as https://wordpress.org/plugins/really-simple-ssl/#installation to achieve this. You should be able to install it from your WordPress panel under the plugins menu.
Before installing it, I suggest removing your attempts to do the redirection from your htaccess & virtualhost files to avoid any possible issues caused by rule collisions etc.
Hope that helps! - Matt.
I’ve been looking through the provided annotations and I can’t seem to find one that toggles the ‘Http to Https’ redirect option on DO load balancers?
( I went through this file: https://github.com/digitalocean/digitalocean-cloud-controller-manager/blob/master/do/loadbalancers.go )
At the moment my setup is like this ( terraform based ) :
...
resource "kubernetes_service" "srv" {
metadata {
name = "..."
namespace = "${var.m_namespace}"
annotations {
"service.beta.kubernetes.io/do-loadbalancer-protocol" = "http"
"service.beta.kubernetes.io/do-loadbalancer-algorithm" = "round_robin"
"service.beta.kubernetes.io/do-loadbalancer-tls-ports" = "443"
"service.beta.kubernetes.io/do-loadbalancer-certificate-id" = "${var.m_certificate_id}"
}
}
spec {
selector {
app = "..."
}
port = [
{
name = "http"
port = 80
protocol = "TCP"
target_port = 8080
}, {
name = "https"
port = 443
protocol = "TCP"
target_port = 8080
}
]
type = "LoadBalancer"
}
}
...
What would be the expected annotations for this ( if it is available)? Or what would be an alternative? For now, I’m making the adjustment manually once the load balancer has been provisioned, but that’s really not the expected way of working for me :/
Loving from Rohit Manglik.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.