Reverse Proxy Apache with Subdirectory

Anton Tananaev8 years ago

There are 3 slashes in the second line.

Adrien548 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 Tananaev8 years ago

Have you enabled WebSocket proxy module in Apache?

Adrien548 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 Tananaev8 years ago

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

JamesHarris7 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 Tananaev7 years ago

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

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