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.
❯ curl -v https://coder.example.io/u/majestic/
* Trying 94.130.xx.xx...
* TCP_NODELAY set
* Connected to coder.example.io (94.130.xx.xx) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
* CAfile: /etc/ssl/cert.pem
CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
* ALPN, server accepted to use h2
* Server certificate:
* subject: CN=*.example.io
* start date: May 8 10:22:18 2020 GMT
* expire date: Aug 6 10:22:18 2020 GMT
* subjectAltName: host "coder.example.io" matched cert's "*.example.io"
* issuer: C=US; O=Let's Encrypt; CN=Let's Encrypt Authority X3
* SSL certificate verify ok.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x7f8dcc80f200)
> GET /u/majestic/ HTTP/2
> Host: coder.example.io
> User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)
> Accept: */*
> Referer:
>
* Connection state changed (MAX_CONCURRENT_STREAMS == 100)!
< HTTP/2 302
< content-type: text/plain
< location: http://coder.example.io/u/majestic/login
< date: Fri, 15 May 2020 11:57:49 GMT
< x-served-by: vscode01
< strict-transport-security: max-age=15768000; includeSubDomains; preload
< referrer-policy: no-referrer-when-downgrade
<
* Connection #0 to host coder.netspeedy.io left intact
* Closing connection 0
Its the same if you add an ending slash or without in the url.
May have seen it, looks like its going from HTTPS to HTTP and then back again in a loop. Theres a line which is different in my original config. Will try adding that for a second.
Seems made no difference, I added in redirect scheme https if !{ ssl_fc } to the backend which is what the old proxy had.
Nothing seems to be in the logs to say whats up.
Ive tried taking out the other redirects and still does it.
This is not a problem related to this redirect. This is simply the backend application not knowing that it runs a) on HTTPS and b) on / instead of /u/majestic/.
Are you saying this worked fine previously with reqrep in the old release?