zoraxy icon indicating copy to clipboard operation
zoraxy copied to clipboard

[HELP] How to create additional locations for a domain

Open maximilianvonamerongen opened this issue 1 year ago • 14 comments

What happened? I have moved from Nginx Reverse Proxy to Zoraxy. I want to transfer my home assistent to Zoraxy and want to move the location (/api, /local and /media) to my settings. As blue print I want to use the config from Nginx.

location ~ ^/(api|local|media)/ {
    include /config/nginx/proxy.conf;
    include /config/nginx/resolver.conf;
    set $upstream_app homeassistant;
    set $upstream_port 8123;
    set $upstream_proto http;
    proxy_pass $upstream_proto://$upstream_app:$upstream_port;
}

Describe what have you tried I have created the virtual directories but then other directories are not working anymore (e.g. /lovelace). How can I just tell Zoraxy for the three endpoints to redirect the traffic?

maximilianvonamerongen avatar Dec 06 '24 13:12 maximilianvonamerongen

Just got it work but this is strange. So Zoraxy is doing it by first hit match Policy. But there is no option to sort the virtual directories in some way. So I need to click on edit and save. After saving it is on top of the list.

So this means I need to adjust this in the right order to have the root folder on top. :D

Maybe there is a future option to adjust the order via drag and drop.

image

maximilianvonamerongen avatar Dec 06 '24 14:12 maximilianvonamerongen

@maximilianvonamerongen uhhh, that is not how you should suppose to use virtual directories. You should first create a proxy rule with your primary domain and add those virtual directories without the root endpoint (I.e. the first slash).

I agree this is something I can improve on by designing the UI to not let user do something like this in the future. But it is quite interesting and unexpected that Zoraxy VD routers can handle rules like this 🤔

tobychui avatar Dec 07 '24 00:12 tobychui

@tobychui the Root endpoint is necessary because otherwise the dashboard is not working anymore.

So normally I just would create the vd for the needed subs. This was my first attempt. But with this setting other subs are not working anymore. After creating the root as well the page worked again.

So maybe I am doing something wrong or is there something else I can do?

But basically I have created the domain as you described.

maximilianvonamerongen avatar Dec 07 '24 07:12 maximilianvonamerongen

@maximilianvonamerongen Can you screenshot your settings here? Virtual directory are rarely used in general homelab settings so I am guessing you are adding virtual directory to the root endpoint?

tobychui avatar Dec 07 '24 07:12 tobychui

image

@tobychui so in general the domain points to the root and I have created three vd's to redirect the traffic. Which is necessary.

No special settings. Just the lets encrypt cert and no ssl check.

All in all it works but pretty strange.

To create this domain I have use the template from swag reverse proxy to catch all endpoints.

maximilianvonamerongen avatar Dec 07 '24 08:12 maximilianvonamerongen

You don't need virtual directory here. All vdir points to the same upstream address in your LAN. Assuming you have the same endpoint in your upstream (e.g. you are using vdir and pointing /local of downstream to upstream:port/local) , you do not need to add the virtual directory as the main proxy rule already contains this routing behavior.

Try remove all your vdir settings from this proxy rule and see if it will work as you expected.

tobychui avatar Dec 07 '24 08:12 tobychui

This is not working and leads to an 404 issue.

It is more or less a redirect.

/api should point to 192.168.2.60/ and not to 192.168.2.60/api

After the creation of the vd /api points to 192.168.2.60/

maximilianvonamerongen avatar Dec 07 '24 09:12 maximilianvonamerongen

Hmm your use case is weird and I never see something like this before.
From what I see from HA doc for reverse proxy using Apache, seems what I am describing is correct

<VirtualHost *:443>
  ServerName home.example.org
  ProxyPreserveHost On
  ProxyRequests off
  ProxyPass /api/websocket ws://localhost:8123/api/websocket <-- This
  ProxyPassReverse /api/websocket ws://localhost:8123/api/websocket <-- And this, are not virtual directory
  ProxyPass / http://localhost:8123/
  ProxyPassReverse / http://localhost:8123/

  RewriteEngine on
  RewriteCond %{HTTP:Upgrade} =websocket [NC]
  RewriteRule /(.*)  ws://localhost:8123/$1 [P,L]
  RewriteCond %{HTTP:Upgrade} !=websocket [NC]
  RewriteRule /(.*)  http://localhost:8123/$1 [P,L]
</VirtualHost>

I am thinking there might be something else in your network that causing all your issues. I will leave this here and see who also use HA can figure out the problem for you.

tobychui avatar Dec 07 '24 09:12 tobychui

Seems to be an interesting issue. 😁

I mean this is the basic installation from HA itself, so I have not made some changes here. So the question is, why I am receiving and 404 if I am calling /api without the setting.

maximilianvonamerongen avatar Dec 07 '24 09:12 maximilianvonamerongen

I am looking about how to proceed with that. So from now it's not possible to do it, right?

location /.well-known/nostr.json { proxy_pass https://URL/nostr.json; }

jjmmbb avatar Jan 26 '25 22:01 jjmmbb

Soo just for you @tobychui, at the end it was an instabil connection. Took me around one month to find. :D This defect is done for me except from the possibility to move the VDs as planned.

But this is more a feature request then a defect.

maximilianvonamerongen avatar Jan 28 '25 08:01 maximilianvonamerongen

This issue should be escalated to a feature request as it represents an important enhancement that is essential for all users. The implementation of this feature will significantly improve the functionality and overall user experience.

jjmmbb avatar Feb 18 '25 22:02 jjmmbb

@jjmmbb I don't think that is necessary. Virtual directory is not location. They are two different logic and hence not compatible. If you want location based routing rules, you should stick with Nginx.

tobychui avatar Feb 18 '25 23:02 tobychui

my Home Assistant just works as expected and have no additional settings set. did you write the proxy in the allow proxyhost in the home aisstant config file ?

FourtyNos avatar Mar 18 '25 11:03 FourtyNos