Secure connection - White screen

Manfred2 years ago

Hi, I have an apache2 running and I want to run traccar in a subdir of my web root like e.g. www-dot-example-dot-org/tracc. I have already a Let's encrypt certificate, running standard Let's encrypt config 000-default-le-ssl.conf.
Instead of creating a separate traccar.conf as described in [Secure Connection] (I never got it running in the last years), I used to copy the mentioned block into my 000-default-le-ssl.conf directly:

ProxyRequests off

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

ProxyPass /tracc/ http://localhost:8082/
ProxyPassReverse /tracc/ http://localhost:8082/
ProxyPassReverseCookiePath / /tracc/

Redirect permanent /tracc /tracc/

This worked for years on an ubuntu 18 server, but now (Jan 2023) I wanted to update to ubuntu 22 and re-installed my server from scratch. All is running fine, including the new traccar installation locally on myserverhostname:8082. Now I wanted to access traccar securely from external via the www-dot-example-dot-org/tracc address.
To do this, I edited the 000-default-le-ssl.conf as described above and performed

sudo apt-get install ssl-cert
sudo a2enmod ssl proxy_http proxy_wstunnel rewrite
sudo service apache2 restart

When navigating to the intended URL (like www-dot-example-dot-org/tracc), the browser shows just a white page, without content.
The current output is:
<body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root" class="root"></div></body>
Error message on the browser console (Firefox):

GET https_www-dot-example-dot-org/tracc/ [HTTP/1.1 200 OK 15ms]
GET https_www-dot-example-dot-org/styles.css [HTTP/1.1 404 Not Found 2ms]
GET https_www-dot-example-dot-org/static/js/main.276d165c.js [HTTP/1.1 404 Not Found 3ms]
GET https_www-dot-example-dot-org/static/css/main.967cebd1.css [HTTP/1.1 404 Not Found 3ms]
GET https_www-dot-example-dot-org/static/js/main.276d165c.js [HTTP/1.1 404 Not Found 4ms]
GET https_www-dot-example-dot-org/logo192.png [HTTP/1.1 404 Not Found 2ms]

So the first line shows success (traccar subdir correctly found), but the server expects the files beyond /opt/traccar/modern in the server root directory. I've tried to solve this with symlinks, but at least a further api directory was missing where I was not able to solve it anymore.

There is a hint in the documentation for [Secure Connection], it says (on the very bottom), I should recompile the modern app for it to work correctly on the new path.
I assume I should follow the [Modern Web App] link?
I further assume I should change the backend server URL in development mode? If yes, where to find the .env-file to change it?
I've tried it with sudo npm install and sudo npm start on ubuntu the command line, but it doesn't work: ENOENT: no such file or directory, open '/opt/traccar/modern/package.json'
Is it at all possible to correct that without an offline development environment such as Eclipse? So just on the Linux commandline?
I'm lost here...

(Note: I had to replace all the URL-like strings by non-URL strings, otherwise I would not be able to submit the post. That's why they do not represent the real examples and especially in the Firefox error log.)

Anton Tananaev2 years ago

I further assume I should change the backend server URL in development mode?

That's not correct. You have configure the router with the base URL. You probably also need to update path for all API calls.

I would recommend checking the source code from older versions of Traccar where the modern app was in the modern subfolder.

Manfred2 years ago

OK, this is unfortunately beyond my know-how in traccar... :-(

Just to complete the details in my post above: When I provide - as a workaround - the files from /opt/traccar/modern in the webserver root /var/www/html via symlinks:

  • static -> /opt/traccar/modern/static/
  • logo192.png -> /opt/traccar/modern/logo192.png
  • service-worker.js -> /opt/traccar/modern/service-worker.js
  • styles.css -> /opt/traccar/modern/styles.css

then I get just the following error message in Firefox:

GET https://www.manfred-roth.de/api/server  [HTTP/1.1 404 Not Found 2ms]

Any idea how I can tell apache2 to access the traccar /api/server directory?