Traccar behind nginx reverse proxy

Felix4 years ago

Hello guys!
I am trying to get my traccar server online behind a nginx reverse proxy but currently it does not work. Maybe you could help me with the problem.
My server is a vm running debian and works well next to some other vms. I access it via ddns right now and my gps trackers all show up.
Now I've installed a nginx server on another vm and want to archive that all my services are available through different subdomains on the internet.

DigitalOcean provides a config generator for nginx which I used successfully for my other services. I also used it for generating the proxy config for my traccar server. The server works somehow atm because I can see the traccar loading wheel if I browse to my configured url on the internet. Unfortunately this is everything that happens, nothing loads and I tried to figure it out myself with help of this forum but this didn't solve my problem. There is no firewall active at my server and I didn't edit the traccar.xml file.

I've attached my .conf file for my nginx server for more details.

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;

    server_name my.domain.com;

    # SSL
    ssl_certificate /etc/letsencrypt/live/my.domain.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/my.domain.com/privkey.pem;
    ssl_trusted_certificate /etc/letsencrypt/live/my.domain.com/chain.pem;

    # security
    include nginxconfig.io/security.conf;

    # logging
    error_log /var/log/nginx/my.domain.com.error.log warn;

    # reverse proxy
    location / {
        proxy_pass http://192.168.178.49:8082;
        include nginxconfig.io/proxy.conf;
    }

    # additional config
    include nginxconfig.io/general.conf;
}

# HTTP redirect
server {
    listen 80;
    listen [::]:80;

    server_name my.domain.com;

    include nginxconfig.io/letsencrypt.conf;

    location / {
        return 301 https://my.domain.com$request_uri;
    }
}

What am I doing wrong? Would really appreciate if someone could help to find the problem.

Thank you!
Felix

Kleent4 years ago

I can see the traccar loading wheel if I browse to my configured url on the internet.

Do you have any blockers such us "uBlock Origin" as a plugin in the used browser ? If so, try disable it for your configured link and see if that could be the display issue.

Felix4 years ago

Hi Kleent,
no I don't. I have adblocker disabled for testing purpose on my traccar site but traccar shows the same problem as before.
I have to add that I can reach my traccar server locally via the ip adress just fine so there should be no browser issue.

Felix

Kleent4 years ago

Have you checked the logs for any relevant information /var/log/apache2/error.log and /opt/traccar/logs/tracker-server.log
There could be a lead from those logs.

Anton Tananaev4 years ago

Probably not Apache, but nginx logs.

Felix4 years ago

Hi guys!
Sorry for my late reply. I've checked the nginx logs. I've censored the IP and my domain:

accesslog: just some GET logs like "92.117.XXX.XXX - - [20/Feb/2020:23:17:16 +0000] "GET /icon.png HTTP/2.0" 200 7941 "https://my.domain.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chr$"
errorlog: nothing

I wanted to check my apache logs as well but could not find them. What is the default directory for the apache2 webserver?

Thank you
Felix

Anton Tananaev4 years ago

What are you using Apache for? I thought you are using nginx.

Felix4 years ago

I thought the webinterface from traccar is from an apache2 webserver? I mean the traccar website works internally and this site have to have some kind of webserver, right?

I use nginx as a reverse-proxy on another vm. It is not installed on the same vm as traccar. My nginx vm is running a headless Ubuntu. My traccar server is running Ubuntu with gui not as I said Debian in the first post - it was quite late...

Anton Tananaev4 years ago

Traccar does have an embedded web server, but it's not Apache. There are no separate logs for it. Everything goes into the standard Traccar logs. If proxying doesn't work, the issue is probably with your nginx setup.

Felix4 years ago

As I said before the loading wheel appears but no map/login is loading. So there is some kind of connection. In my opinion this is not the proxys fault? What do you think?

Anton Tananaev4 years ago

If you can connect directly but not through proxy, then it's a proxy fault. Very trivial test.

Felix4 years ago

Okay, has somebody experience with nginx? Especially in relation with traccar.
Thank you!

Kleent4 years ago

I have to add that I can reach my traccar server locally via the ip adress just fine so there should be no browser issue.

Did you also installed apache on the same machine as Traccar ? if so then you have a double proxy situation.
In any case, the above quote suggests you have a network/firewall issue, running the vm's on premise ? (as opposed to hosting)
Typing the local ip address where the traccar server resides will resolve the default traccar integrated server, hence the successful display of the page.

However, resolving traccar from outside of your local network is handled by the reverse proxy nginx or apache.
As Anton put it, its nginx log files that you should look at for errors.
Can you reach (ping) the traccar vm from within the nginx vm ? Integrated VM switches (nic adapters) on top of your physical topology can be at times a nightmare to troubleshoot.

Chances are your issue is in that maze.

br2e4 years ago

hello call me email or whatsapp [removed]

Anton Tananaev4 years ago

No personal contact details on the forum please.