Information - Auto-forward http to https

Turbovix7 years ago

Anton, you may add the information below on the following page (https://www.traccar.org/secure-connection/).
Important for proper site configuration for SSL use.
Basically it automatically redirects the http protocol to https.

Thank you!
It is necessary to enable the apache module responsible for the targeting with the command below:

# sudo a2enmod rewrite

<IfModule mod_ssl.c>

         <VirtualHost _default_:80> 

               ServerName demo.traccar.org 
               Redirect / https://demo.traccar.org

         </VirtualHost> 


        <VirtualHost _default_:443>

                ServerName demo.traccar.org
                ServerAdmin webmaster@localhost

                DocumentRoot /var/www/html

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

                ProxyPass / http://localhost:8082/
                ProxyPassReverse / http://localhost:8082/

                SSLEngine on
                SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
                SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key

        </VirtualHost>
</IfModule>
Anton Tananaev7 years ago

I believe it's out of scope for the documentation because it's not really related to Traccar, but we can keep this forum topic because it might be useful for others.

Turbovix7 years ago

OK thank you!

Edilon Carvalho 5 years ago

Which file do I insert these changes into? Display the full path please. I'm wondering if it's tracar.conf or 000-default.conf

Turbovix5 years ago

Hi, you can do both or any other file you create as long as it ends with (.conf), however if you create (traccar.conf), you must enable apache with the command (#sudo a2ensite traccar) , because by default the active one is (000-default.conf). I like to back up the original settings without any changes, something like (000-default.conf.backup), using the #cp command in #Linux and then I edit (000-default.conf) and put the necessary settings. If anything goes wrong, I just have to go back to the original backup settings.

Edilon Carvalho 5 years ago

Could you help me?
I put a domain for testing but when I type it loads the secure page for a second but directs it to the server IP. If you can add me to Skype to help me thank you the name is: Edilon.

Edilon Carvalho 5 years ago

The server is opening on HTTPS now but logs in only if accessing with the IP and port, by the domain No. Is there a directory that requires permission?

Turbovix5 years ago

Friend it is impossible for anyone to help you if you do not put the settings here!
The guidelines at https://www.traccar.org/secure-connection/ are sufficient for the proxy to function as expected.
There are cases that you need to read the Apache or Nginx documentation to understand how the configuration of both works and so we make the necessary settings for specific cases!

Edilon Carvalho 5 years ago

It's running on Apache. I changed the proxy settings but did not resolve.

I visualized the tip of the website below reported by Antony but did not understand in what file I should make the change. The site is a little slow to open
https://pod.thomasdalichow.de/posts/408

Edilon Carvalho 5 years ago

Now it is running with the certificate but there is another problem, when trying to login does not allow access saying that is trying to access an insecure page. Squeezing F12 I noticed that is the IP of my server and the file that is linked to this call looks like contains this information:

$("#login-form").submit(function(event){
        event.preventDefault();

        let data = $("#login-form").serialize();
        $.ajax({
                url: "http://191.252.203.199/api/login.php", // Url Api php, localizada na pasta login/api/login.php
                type: 'POST',
                dataType: 'JSON',
                data: data,
                cache: false,

                success :  function(response){
                        if(response.data.length == 1){
                                window.location = 'http//191.252.203.199:8082'; // Url a ser redirecionada, Ou seja seu servidor traccar  
                        }
                        else{
                                $("#erro-login").html('<strong style="color:red"> * nome de usuário ou senha inválido </strong>');
                        }
                }

        });
});

Test domain is www.baixebooks.com.br

Edilon Carvalho puedes compartir tu archivo login.php y api.php?