Apache proxy subdir

keeka8 years ago

Hi,

Thank you for creating traccar, Anton.

I have traccar running on one host and want to proxy it via a subdir in apache, running on another host.
I have successfully proxied traccar from / based on the suggested apache conf.
Now I'm trying to do it using a subdir (/tracker/):

    ProxyPass /tracker/api/socket ws://tracker:8082/api/socket
    ProxyPassReverse /tracker/api/socket ws://tracker:8082/api/socket
    ProxyPass /tracker/ http://tracker:8082/
    ProxyPassReverse /tracker/ http://tracker:8082/

However some of the url's the browser encounters are relative to / e.g. /l10n/.
I handled this with another specific proxy config, then I encounter others. I'd rather not add more rules as it might break some other application on the apache server in future.

What's the best way to manage this? Should I be looking at SetOutputFilter and/or ProxyHTMLURLMap?

Many thanks.

Anton Tananaev8 years ago

I think the best way is to fix it in the code. Send me a pull request if you manage to do that.

keeka8 years ago

Thanks. I have done it this way for the time being and it is working for my needs. The order is significant.

    ProxyPass /tracker/ http://tracker:8082/
    ProxyPassReverse /tracker/ http://tracker:8082/
    ProxyPass /api/socket ws://tracker:8082/api/socket
    ProxyPassReverse /api/socket ws://tracker:8082/api/socket
    ProxyPass /api/ http://tracker:8082/api/
    ProxyPassReverse /api/ http://tracker:8082/api/
    ProxyPass /l10n/ http://tracker:8082/l10n/
    ProxyPassReverse /l10n/ http://tracker:8082/l10n/

I'm only viewing last location and track logs for existing devices at the moments. So more urls may need to be handled for full function.

Anton Tananaev8 years ago

I have changed everything to use relative URLs, so next version should work without mapping socket, api and l10n folders separately.

keeka8 years ago

That's great news. Thank you!