help accessing code server through HAProxy

Started by keyboardDabbler, April 23, 2022, 07:31:42 AM

Previous topic - Next topic
April 23, 2022, 07:31:42 AM Last Edit: April 23, 2022, 09:49:43 AM by keyboardDabbler
I was hoping someone can help me get the live server extension working within the code-server docker. I rely on being able to see my changes live and am struggling to access the hosted port 5500.cs.example.com

I have HAProxy working with ACME & Cloudflare. Following this great tutorial (https://forum.opnsense.org/index.php?topic=23339.0). I can access code-server via cs.example.com but when I launch the live server extension, I should be able to access this via 5500.cs.example.com.

by adding a extra port in the container I am able to locally access live server via, http://serverip:5500. I tried to create a new backend/front end pointing here but this did not work.

Working setup sofar
Cloudflare = A record, *, IP
ACME > Certificates = Common name, *.example.com
HAProxy > front end & backend points to cs local ip & port

Does HAProxy have something similar to the EXTRA_DOMAINS argument that is referenced below?

After searching the LSIO discord I found the below support using their SWAG container but I cant implement this with my setup (HAProxy).
Quote
aptalca — 16/01/2022
you just add *.code-server.domain.com into EXTRA_DOMAINS in SWAG arguments, create a wildcard cname for *.code-server and set the server address in code server env vars PROXY_DOMAIN. After that code server will let you access any port at https://port.code-server.domain.com

MuadDDib — 16/01/2022
I'm using CloudFlare DNS, so I have my A domain for domain.com then a CNAME for code.domain.com

aptalca — 16/01/2022
you need another cname for *.code.domain.com

MuadDDib — 16/01/2022
Now I have to create a new CNAME for *.code.domain.com like the image I'll show next

aptalca — 16/01/2022
if you're using code instead of code-server, you'll have to edit the proxy conf for code server to edit both instances of code-server to code on this line:

aptalca — 16/01/2022
what validation method are you using? http?

MuadDDib — 16/01/2022
yep
I thought that was the de facto for CF DNS

aptalca — 16/01/2022
ah, then you can't do wildcard. change the cname to 5500.code

MuadDDib — 16/01/2022
ok give me a sec

aptalca — 16/01/2022
and add 5500.code.domain.com to EXTRA_DOMAINS
only port 5500 will work, but it will get you go live
I gotta go to bed

MuadDDib — 16/01/2022
@aptalca just wanted to let you know that it worked almost flawlessly!