Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HELP] How to create additional locations for a domain #417

Open
maximilianvonamerongen opened this issue Dec 6, 2024 · 9 comments
Open
Labels
help wanted Extra attention is needed

Comments

@maximilianvonamerongen
Copy link

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 maximilianvonamerongen added the help wanted Extra attention is needed label Dec 6, 2024
@maximilianvonamerongen
Copy link
Author

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

@tobychui
Copy link
Owner

tobychui commented Dec 7, 2024

@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 🤔

@maximilianvonamerongen
Copy link
Author

@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.

@tobychui
Copy link
Owner

tobychui commented Dec 7, 2024

@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?

@maximilianvonamerongen
Copy link
Author

maximilianvonamerongen commented Dec 7, 2024

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.

@tobychui
Copy link
Owner

tobychui commented Dec 7, 2024

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.

@maximilianvonamerongen
Copy link
Author

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/

@tobychui
Copy link
Owner

tobychui commented Dec 7, 2024

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.

@maximilianvonamerongen
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants