How to bind Traccar app to a single domain?

akiosdev4 years ago

Right now, if I run a Docker image of Traccar, it binds to 0.0.0.0:<PORT>
thus I can access Traccar in all my domains of my VPS just by putting :PORT after the domain, and even using both of My IP addresses.

How can I bind Traccar to be accessed by only one domain?
I tried to use web.address in the /var/docker/traccar/traccar.xml
by putting my domain name like this:

<entry key='web.address'>domain.com</entry>

or using my secondary Ip address:

<entry key='web.address'>X.X.X.X</entry>

both of them returns 'invalid address' in the log, so I am not sure how I am supposed to do this.
maybe there is a way to make the app accessible only by a path of my site?
like: mydomain.com/api/traccar

how can I make this work?

VPS: CENTOS 7.8 kvm

Anton Tananaev4 years ago

You would have to set up proxy. The web.address can only be used for interface binding, not for domains.

Anton Tananaev4 years ago

Unless you have different IP addresses. In that case it should work.

akiosdev4 years ago

For some reason my second IP won't work, I think is because apache is handling it:

 Web server start failed - Address not available - BindException (... < WebServer:172 < Main:145 < *:110)

Also every time I run the server it gives a systemD warning, but IDK if that is important:

Error loading shared library libsystemd.so: No such file or directory
Native library (linux-x86-64/libsystemd.so) not found in resource path ([file:/opt/traccar/tracker-server.jar]) - UnsatisfiedLinkError (... < HealthCheckService:39 < Main:115 < *:148 < *:110)

I don't think even the Main IP Address would work, because it says invalid when I try to use it
in my Node Express servers as well, the only IP that works is 0.0.0.0, but that hosts on both IP's.

But how would I setup a Proxy? I have to use Apache?

Anton Tananaev4 years ago

Yes, use Apache, especially because you already have it running.

https://www.traccar.org/secure-connection/