By ryangiglio
I am using LetsEncrypt to add SSL certs to all my domains. I used the “force redirect to https” option when I set up the cert, which added the redirect to my *:80 virtualhost and created a *:443 virtualhost with the correct config. However, it’s behaving really strangely.
If you go to http://blog.ryangiglio.com, it 301 redirects you to http://www.blog.ryangiglio.com. Nowhere in my config do I see a reason for that to happen, and I can’t figure out how to view the level of logs that would help me debug the issue.
Here are my conf files:
blog.ryangiglio.com.conf
<VirtualHost *:80>
ServerName blog.ryangiglio.com
RewriteEngine on
RewriteCond %{SERVER_NAME} =blog.ryangiglio.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
blog.ryangiglio.com-le-ssl.conf
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin webmaster@localhost
ServerName blog.ryangiglio.com
DocumentRoot /var/www/blog.ryangiglio.com/public_html
ErrorLog /var/www/blog.ryangiglio.com/error.log
CustomLog /var/www/blog.ryangiglio.com/access.log combined
<Directory /var/www/blog.ryangiglio.com/public_html/>
Options FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
</Directory>
SSLCertificateFile /etc/letsencrypt/live/blog.ryangiglio.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/blog.ryangiglio.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
</IfModule>
Any help would be appreciated. Thanks!
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 @ryangiglio
Looking at those two configurations, should never result in 301 to www.sub.site.com
Are you sure there might not be hiding a configuration somewhere else? Or maybe your .htaccess has some redirects?
Try running this to list all the VirtualHosts: sudo apache2ctl -S
I’m seeing something entirely different on my end, though neither redirect to anything when I access them.
When I visit https://blog.ryangiglio.com/, I see one site with two posts. It doesn’t redirect to www.
When I visit http://www.blog.ryangiglio.com/, I see an entirely different website.
…
When checking the IP they resolve to, they both resolve to the same IP address, so the issue here is configuration. Are there any other configuration files that you can provide? Something is separating the two and pointing to two entirely different directories from what I’m seeing on my end.
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.