HTTP to HTTPS redirect issue

Michał Piasecki5 years ago

I already looked at https://www.traccar.org/forums/topic/information-auto-forward-http-to-https/, as well as many online guides how to redirect HTTP to HTTPS with Apache.

I'm not sure whether I should ask here or on Stack Overflow sister site. Whatever I try my domain just won't switch to secured protocol automatically and I thought it might be a Traccar issue, since when I tried to install SSL certificate with LetsEncrypt, Traccar had to be stopped because Certbot couldn't find its verification directory. Then again I'm just a hobbyist, I don't know much about networks or servers (though I learned a great deal so far).

This is my virtual host file

< IfModule mod_ssl.c >
< VirtualHost *:80 >
RewriteEngine on
RewriteCond %{SERVER_NAME} =my.domain.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
< /VirtualHost >

< VirtualHost *:443 >
ServerName my.domain.com
#ServerAlias my.domain.com
DocumentRoot /var/www/html
ServerAdmin admin@localhost

ProxyPass /api/socket ws://localhost:80/api/socket
ProxyPassReverse /api/socket ws://localhost:80/api/socket

ProxyPass / http://localhost:80/
ProxyPassReverse / http://localhost:80/

SSLEngine on
SSLOptions +StrictRequire
SSLProtocol TLSv1
ServerAlias my.domain.com
SSLCertificateFile /etc/letsencrypt/live/my.domain.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/my.domain.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
< /VirtualHost >
< /IfModule >

There aren't any spaces around <*>s actually, Markdown just wouldn't display them without spaces.

Anton Tananaev5 years ago

What port is your Traccar instance using?

Michał Piasecki5 years ago

It uses port 80.

Anton Tananaev5 years ago

I don't understand then. How do you expect Apache to use port 80 then, if Traccar already uses it?

Michał Piasecki5 years ago

Jesus christ I'm stupid. I'll try changing it next time I'm at work. Thanks, and sorry for the trouble.