Nginx and traccar in subfolder

oharahay2 years ago

Dear friends

I hosting multiple websites with nginx, SSL already set up. Traccar on the same machine as nginx.

How to make Traccar available as a subfolder of an already existing domain?

This is my nginx config
Traccar working on localhost:8083 port

     location /gps/ {
         proxy_set_header        Host                 $host;
         proxy_set_header        X-Forwarded-Host     $host;
         proxy_set_header        X-Forwarded-Server   $host;
         proxy_set_header        X-Real-IP            $remote_addr;
         proxy_set_header        X-Forwarded-For      $proxy_add_x_forwarded_for;

         proxy_set_header        Upgrade              $http_upgrade;
         proxy_set_header        Connection           "upgrade";
         proxy_http_version      1.1;

         proxy_cookie_path       /api /gps/api;

         proxy_redirect          http://127.0.0.1:8083/           /gps/;
         proxy_redirect          ws://127.0.0.1:8083/api/socket   /gps/api/socket;
         proxy_pass              http://127.0.0.1:8083/;

         proxy_read_timeout      600s;
      }

But I have problem with "modern" skin.

This is nginx log

104.28.xxx.xxx - - [27/May/2022:12:50:36 +0300] "GET /gps/ HTTP/1.1" 200 462 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.5 Safari/605.1.15"
104.28.xxx.xxx - - [27/May/2022:12:50:36 +0300] "GET /gps/app.css HTTP/1.1" 200 1134 "https://mx3.sat.com/gps/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.5 Safari/605.1.15"
104.28.xxx.xxx - - [27/May/2022:12:50:36 +0300] "GET /gps/load.js HTTP/1.1" 200 7834 "https://mx3.sat.com/gps/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.5 Safari/605.1.15"

104.28.xxx.xxx - - [27/May/2022:12:50:36 +0300] "GET /modern/ HTTP/1.1" 404 266 "https://mx3.sat.com/gps/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.5 Safari/605.1.15"
Anton Tananaev2 years ago

You need to recompile the modern app to support your path and also you need to remove/update redirect location.

oharahay2 years ago

Anton thanks for the answer. tell me where i can find instructions on how to properly assemble modern.app.

oharahay2 years ago

as an option, can someone tell me a working way how to connect from a docker container (if I install traccar in docker) to mysql running on a locahost? (I use Debian 10)

Anton Tananaev2 years ago

There's documentation in the repo on how to compile the app.

Abner Velascoa year ago

hi oharahay, were you able to resolve the problem? Can you tell me, how did you do it?