Traccar failed with Nginx and SSL Let's Encrypt

Abner Velasco5 years ago

I have a problem installing Traccar behind a Nginx server with Let's Encrypt

This is the Nginx code

server {
        listen 80 default_server;
        listen [::]:80 default_server;

        root /var/www/html;
        index index.html index.htm index.nginx-debian.html;

        server_name _;

        location / {
                try_files $uri $uri/ =404;
        }
}

server {
        server_name portal.protecsystems.com.mx www.portal.protecsystems.com.mx; # managed by Certbot
        location / {
                proxy_pass         http://localhost:5000;
                proxy_http_version 1.1;
                proxy_set_header   Upgrade $http_upgrade;
                proxy_set_header   Connection keep-alive;
                proxy_set_header   Host $host;
                proxy_cache_bypass $http_upgrade;
                proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header   X-Forwarded-Proto $scheme;
        }

        listen [::]:443 ssl ipv6only=on; # managed by Certbot
        listen 443 ssl; # managed by Certbot
        ssl_certificate /etc/letsencrypt/live/portal.protecsystems.com.mx/fullchain.pem; # managed by Certbot
        ssl_certificate_key /etc/letsencrypt/live/portal.protecsystems.com.mx/privkey.pem; # managed by Certbot
        include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
        ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}

server {
    if ($host = www.portal.protecsystems.com.mx) {
        return 301 https://$host$request_uri;
    } # managed by Certbot

    if ($host = portal.protecsystems.com.mx) {
        return 301 https://$host$request_uri;
    } # managed by Certbot

        listen 80 ;
        listen [::]:80 ;
    server_name portal.protecsystems.com.mx www.portal.protecsystems.com.mx;
    return 404; # managed by Certbot
}

and this is my traccar configuration file:

<? xml version = '1.0' encoding = 'UTF-8'?>

<! DOCTYPE properties SYSTEM 'http://java.sun.com/dtd/properties.dtd'>

<properties>

    <entry key = "config.default"> ./conf/default.xml </ entry>

    <entry key = 'web.port'> 5000 </ entry>
    <entry key = 'web.enable'> true </ entry>
    <entry key = 'geocoder.enable'> true </ entry>

    <entry key = 'database.driver'> com.mysql.jdbc.Driver </ entry>
    <entry key = 'database.url'> jdbc: mysql: // localhost: 3306 / traccar? allowMultiQueries = true & amp; autoReconnect = true & amp; useUnicode = yes & characterEncoding = UTF-8 & sessionVariables = sql_mode = '' </ entry>
    <entry key = 'database.user'> root </ entry>
    <entry key = 'database.password'> password </ entry>

    <entry key = 'server.timeout'> 120 </ entry>
</ properties>

The problem that throws me is that I get a message that says error on the web

Ernesto Vallejo5 years ago

All your entry keys have whitespaces in between ?

trackinguser4455 years ago
trackinguser4455 years ago

Abner: did you solve this problem?