Traefik using subfolder instead of subdomain

ravenblight

Dabbler
Joined
Oct 28, 2021
Messages
26
Hi
I'm newbie in all networking cases, but I've managed to setup my homelab with scale traefik as my main reverse proxy and it is bind with ks8 gateway pointing to my AdGuard Home dns. All supported by propper certs, and public domain (where needed, not all aps are exposed). This setup works perfect, also with External Services from truecharts, and my question is about possibility of setting up external service (or ingress) to point subfolder to diffirent port?

For example I have external service homeassistant on domain
Code:
ha.mydomain.com -> 192.168.1.50:8123 

and this is working but I have some problems to correctly access apps on homeassistant. I've researched possiblity to set something like:
Code:
ha.mydomain.com/app -> 192.168.1.50:someport

to point to diffirent port but in same ip range. Is this possible, I found difficult to find usefull answer for this.
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
Use the TrueCharts app called External Service, then set it like this:

You'll need to add the path to have one there to work with...

1650977272992.png
 

truecharts

Guru
Joined
Aug 19, 2021
Messages
788
Use the TrueCharts app called External Service, then set it like this:

You'll need to add the path to have one there to work with...

View attachment 55033

One would, most likely, also need specific traefik middleware, otherwise it would only do:
ha.mydomain.com/app -> 192.168.1.50:someport/app
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703

Migsi

Dabbler
Joined
Mar 3, 2021
Messages
40
Might be a good point to hint to my thread where I was facing a similar issue (which looks more lika bug) regarding prefix/redirectRegex: https://www.truenas.com/community/threads/traefik-redirect-issues.100774/

Apparently the redirect does not work properly, but will append the port to the path you define (for whatever reason). If you get this to work, I'd be happy to hear what I missed.
 

ravenblight

Dabbler
Joined
Oct 28, 2021
Messages
26
Thanks for very fast reply, I've tried to setup regex redirect middleware, and plain redirect was working
sort of..
Code:
 https://ha.mydomain/app => https://ip:9541 

To plain ip worked but i've lost domain name in url it just redirected to ip address.
Code:
 https://($1)/app =>  https://x.x.x.x:9541 

I've tried today with truecharts app emu js which have two web interfaces
config on : 10130 (traefik catches it first in ingress, and I don't want to expose this service)
actual app on 10124 (this should be exposed)
I tried to first configure subfolder for app so I've added
Code:
^(.*)/app  => $1:10124

Regex101 replaces this nice, and without middleware emu.mydomain.com:10124 works fine
But when I've enabled middleware on emu app, it redirected me to right address but with ssl error
ERR_SSL_PROTOCOL_ERROR
Is there any way to hide port in url and to maintain emu.mydomain.com/app, and redirection under the hood?
 

ravenblight

Dabbler
Joined
Oct 28, 2021
Messages
26

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
It's probably worth mentioning that you don't always need to do the redirect if the app already supports re-writing the path...

Most of the common apps do allow for the path to be set (the setting might be called something like URL base or you may need to search around for it a bit in the general or UI settings.

Where you can get the app to know that it's in a subfolder, the first path setting should be all that's needed in Traefik
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703

ravenblight

Dabbler
Joined
Oct 28, 2021
Messages
26
It's probably worth mentioning that you don't always need to do the redirect if the app already supports re-writing the path...

Most of the common apps do allow for the path to be set (the setting might be called something like URL base or you may need to search around for it a bit in the general or UI settings.

Where you can get the app to know that it's in a subfolder, the first path setting should be all that's needed in Traefik
I've played with emujs provided by truecharts, so I don't think that I can combine with rewriting, also that are 2 diffirent services under it with diffirent ports.
 

truecharts

Guru
Joined
Aug 19, 2021
Messages
788
to be clear here:
We generally advice subdomains for different services, as there is a whole host of issues you can get (and are getting)n into when doing path redirects. It hugely depends on a lot of circumstances if it works for your specific usecase and which cases/changes are required,
 

ravenblight

Dabbler
Joined
Oct 28, 2021
Messages
26
I've give up my attempts in doing this, I lack knowledge to dig inside of how this works, and i think that homeassistant ingress also blocks this.
 

truecharts

Guru
Joined
Aug 19, 2021
Messages
788
i think that homeassistant ingress also blocks this.

That's not likely.
But you've not given enough information to comment.

Please also be aware that most of our staff is not very active on these forums, as we've our own support resources.
 

ravenblight

Dabbler
Joined
Oct 28, 2021
Messages
26
That's not likely.
But you've not given enough information to comment.

Please also be aware that most of our staff is not very active on these forums, as we've our own support resources.
Yes, I was trying to submit discord support ticket, but it was closed with enigmatic anwser that this is my problem. Before I had chance to talk with somebody. Im not familiar with discord setup, for me it is chaotic and not very user friendly. So I gone here, thinking that maybe somebody had same idea like me. I can try again with discord.
 

truecharts

Guru
Joined
Aug 19, 2021
Messages
788
Yes, I was trying to submit discord support ticket, but it was closed with enigmatic anwser that this is my problem. Before I had chance to talk with somebody. Im not familiar with discord setup, for me it is chaotic and not very user friendly. So I gone here, thinking that maybe somebody had same idea like me. I can try again with discord.

That's odd, because we do not have any support ticket with "subdomain" it looks like.
Most likely your ticket got closed because you didn't include the information that is listed as "required", just like we stated here... even when filing a support ticket we have a minium amount of information our staff requires to respond to any request for help.
 

ravenblight

Dabbler
Joined
Oct 28, 2021
Messages
26
That's odd, because we do not have any support ticket with "subdomain" it looks like.
Most likely your ticket got closed because you didn't include the information that is listed as "required", just like we stated here... even when filing a support ticket we have a minium amount of information our staff requires to respond to any request for help.
Yes because I've asked about subdirectory, I think, I don't know how to display my discord history. As I said, I've give up on subdirectory way, this is for now much bigger than I though. I'll try to submit another ticket on discord, about multi service app like emujs with some more details.
 
Top