How to enable SSL for website AND traccar?

IoSonoPiero2 years ago

Hello people,
I'm going mad because I cannot achieve my idea after I've seen the forum, the configuration section and various web posts.

I have a website that is currently working with SSL. So, if you visit:
https://mysite.info you access my website pages.

Now, I'd like to know HOW I can access Traccar by visiting HTTPS://mysite.info:8082.
Currently, Traccar is working and accessible via HTTP://mysite.info:8082 (without HTTPS).

Can someone help me, please?
Regards,
Piero

Anton Tananaev2 years ago

You need to set up a proxy. We have a documentation page for this specifically.

IoSonoPiero2 years ago

Ok, thanks.
Maybe the proxy configuration that is available at https://www.traccar.org/secure-connection/?

If yes, I've already used that, but using that configuration, I only obtain that visiting:
HTTPS://mysite.info I visit the Traccar website.
And that is not my achievement, sadly.

Anton Tananaev2 years ago

Obviously you have to adjust the configuration to achieve what you want. It just gives you an idea on what you need to do.

IoSonoPiero2 years ago

Very good.
Thank you, I'll figure out how to do that.

MEGATRACKGPS SAS2 years ago

I have all the commands saved to add an ssl certificate to the ubuntu server if you need them I can send them to you

IoSonoPiero2 years ago

Hello YeiserGS11, I've already added a certificate and the website uses correctly the SSL.
I'm looking for a way to enable it on port 8082.
I've tried a lot of things but without success. On first post I've explained what I need.
If you solved that, I'll be very happy to hear from you!

Track-trace2 years ago

Good Idear to tell if you use Apache or Nginx as webserver.

IoSonoPiero2 years ago

Correct.
I use Apache webserver.

Track-trace2 years ago

So what is the real content of your

/etc/apache2/sites-available/traccar.conf

Content for the site configuration (replace "demo.traccar.org" with your domain):

<VirtualHost *:80>
  ServerName demo.traccar.org
  Redirect / https://demo.traccar.org/
</VirtualHost>
<IfModule mod_ssl.c>
        <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>
IoSonoPiero2 years ago

@Track-trace
Sorry but I'm unable to understand.
The fragment you posted is related to https://www.traccar.org/secure-connection/
Using that configuration, with specific modifications to adapt the certificates path,
I can't access my website anymore, but I access directly to Traccar.

The file's actual content in /etc/apache2/sites-available/mysite.info-le-ssl.conf is:

<IfModule mod_ssl.c>
<VirtualHost *:443>
    ServerAdmin webmaster@localhost
    ServerName mysite.info
    ServerAlias www.mysite.info
    DocumentRoot /var/www/mysite.info
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/mysite.info/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/mysite.info/privkey.pem
</VirtualHost>
</IfModule>

Regards,
Piero

Anton Tananaev2 years ago

Why are you not using a different port? Isn't that what you originally asked about?

IoSonoPiero2 years ago

Ok, so:
I posted the content of my current file /etc/apache2/sites-available/mysite.info-le-ssl.conf
that enables me to visit currently my website (a regular website) with SSL support.

My request (I apologize if I expressed myself wrong above in the first post) is for help to let me visit
https://mysite.info -> access to website
https://mysite.info:8082 -> access to Traccar

I've tried several solutions, but no one is working.
Of course, I can visit http://mysite.info:8082 (without SSL) and use Traccar.
I only like to use SSL for Traccar.

Regards,
Piero

Anton Tananaev2 years ago

Can you show us the Apache configuration where you actually attempted to configure what you want with two different ports?

Track-trace2 years ago

@IoSonoPiero How could you think that it could work without adding Proxypass to you conf file ?
I do not see it in your Conf

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

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