Hey Guys,
I got a little problem with a small piece of code which I wondered if anyone had an idea how to convert this to be HAProxy v2.1+ compliant.
I have used this code for the past year or so without issues, it rewrites the url so it works with code-server and supporting multi users based on /u/username scheme.
I have tried several versions but I am not winning.
Exact line which I believe needs changing:
reqrep ^([^\ :]*)\ /u/majestic/(.*) \1\ /\2
Below I am enclosing the full config in case its somewhere else. If anyone has any ideas or how to write this better, I would really love to hear form you. Thank you.
Full HAProxy code
# vscode (majestic)
acl vscode_majestic hdr(host) -i coder.example.io
acl vscode_majestic_req path_beg /u/majestic/
acl vscode_majestic_req path /u/majestic/
http-request redirect scheme https drop-query append-slash if { path -m str /u/majestic }
use_backend vscode_majestic if vscode_majestic_req
# vscode (majestic)
backend vscode_majestic
redirect scheme https if !{ ssl_fc }
reqrep ^([^\ :]*)\ /u/majestic/(.*) \1\ /\2
server vscode01 172.27.1.102:8081 check
VS Code server systemd script
[Unit]
Description=Visual Studio Code Server (majestic)
After=network.target
[Service]
EnvironmentFile=/data/coder/majestic/.env
ExecStart=/data/coder/majestic/bin/code-server --base-path /u/majestic --host 0.0.0.0 --port 8081 --user-data-dir /data/coder/majestic/user-data /data/coder/majestic/projects
User=majestic
Restart=always
RestartSec=1
[Install]
WantedBy=multi-user.target
Versions I have tried:
http-request replace-path ^([^\ :]*)\ /u/majestic/(.*) \1\ /\2
http-request set-path "%[path,regsub(^/u/majestic/,/)]"
http-request replace-path ^([^\ ]*\ /)u/majestic[/]?(.*) \1\2
Any tips/advise, I would be extremely grateful.
Kind Regards,
Majestic
9 posts - 2 participants