Reverse Proxy Apache with Subdirectory

Anton Tananaev 9 years ago

There are 3 slashes in the second line.

Adrien54 9 years ago

Sorry, mistake in copy/paste the config file is good in my server like this :

ProxyPass /api/socket ws://192.168.1.103:8082/api/socket
ProxyPassReverse /api/socket ws://192.168.1.103:8082/api/socket

ProxyPass / http://192.168.1.103:8082/
ProxyPassReverse / http://192.168.1.103:8082/

No work...

I will try Apache and Traccar in the same VM

Anton Tananaev 9 years ago

Have you enabled WebSocket proxy module in Apache?

Adrien54 9 years ago

Hello,

Yes the module is activated


apachectl  -t -D DUMP_MODULES
Loaded Modules:
 ...
 proxy_module (shared)
 proxy_http_module (shared)
 proxy_wstunnel_module (shared)
...
Anton Tananaev 9 years ago

Then I'm not sure what the problem is. It worked for me, so something must be missing in your setup.

JamesHarris 9 years ago

I figured out this bug. I had used the old notes on setting up sslproxy from
https://pod.thomasdalichow.de/posts/408 . I had the /gps/ subdirectory proxying to the root of traccar. After upgrading to 3.11 I was unable to login via ssl. The issue was the JSESSIONID cookie is now set with the path /api. Apache doesn't rewrite the cookie path so the browser is at /gps/* and receives a set-cookie with path /api/ the cookie is ignored as a security violation and all .../api/ requests fail. The fix is to use ProxyPassReverseCookiePath to fixup cookie paths.

I am now using

ProxyRequests off

ProxyPass /gps/api/socket ws://127.0.0.1:8082/api/socket
ProxyPassReverse /gps/api/socket ws://127.0.0.1:8082/api/socket

ProxyPass /gps/ http://127.0.0.1:8082/
ProxyPassReverse /gps/ http://127.0.0.1:8082/
ProxyPassReverseCookiePath / /gps/

Redirect permanent /gps /gps/

This properly puts the traccar server under /gps/ and adds a redirect should someone forget the slash.
I would suggest updating the https://www.traccar.org/secure-connection/ or add another example using subdirectories which requires the cookie path rewrite.

Anton Tananaev 9 years ago

Thanks for sharing the information. I have updated the page with your config example:

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