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

[Feature]: Second server url for fallback / local ip to external domain name swtich #308

Closed
EnderPicture opened this issue Jul 5, 2022 · 26 comments
Labels

Comments

@EnderPicture
Copy link

Feature detail

It would be nice to automatically switch between uploading from the local network connection when at home to viewing from any location when outside.

example:

  • when at home, we connect to 192.168.0.25:2283 for high speed local file transfer to server.
  • when outside, we connect to photo.example.com to view photos/upload at slower speeds.

Platform

Mobile App

@bertmelis
Copy link

Isn't the domain resolved to the same machine?

@EnderPicture
Copy link
Author

Yes, but connecting through local IP transfers way faster.

  • The server is locally hosted
  • Server is connected to the domain via cloud flair tunnel

@bo0tzz
Copy link
Member

bo0tzz commented Jul 7, 2022

The usual solution for this is split DNS: The domain is configured externally as usual, but on your local network you run a DNS server that resolves it to the local IP.

@alextran1502
Copy link
Contributor

I think we can close this issue as it is better to be handled on the local network DNS.

@jon-f-novastor
Copy link

jon-f-novastor commented May 8, 2023

What is the reluctance to implement a feature that would allow the mobile app to be able to switch endpoint addresses easily, like at least from an internal endpoint to an external endpoint address? It doesn't seem like that would take much added logic just to allow the user to configure two endpoint URLs, one as "internal" and one as "external" to be able to choose from upon mobile app load (if the two endpoint URLs were in fact configured first in settings). Not all of us that host this app are network experts to be able to setup and maintain split DNS, or want to maintain our own DNS servers that then must be utilized across all friends and family members mobile devices, who don't even live at the same home location in some cases. It doesn't seem like having a config setting to enter in your endpoint URLs one time in the mobile app UI and then present those two "internal" or "external" endpoint URL choices on mobile app load would be that hard to implement? I'm just curious why the reluctance for this fairly simple mobile app feature that seems like many have asked about and need.

@PeterBasista
Copy link
Contributor

I addressed this question right at the beginning when I started using immich, I also created a discussion about it, and I also got the answer that I should use DNS somehow. Since I am not familiar with the languages immich is written in, I unfortunately don't know the complexity or difficulty of the implementation. But I find it fairly simple to check the ssid of the network at startup, if it is "xyz" then use internal otherwise external url/address. But since they always say about "just use split DNS" so I want to describe my problem and solution.

My network setup is quite simple. Router and then a Pihole (2x), this pihole is also as the main DNS server (I also have to rely on it since when I only had it as primary my router sometimes changed its mind about using secondary and I couldn't do connect to immich.Thus both primary and secondary I have a pihole instance.) In the pihole I set the url for immich as a translation to the internal address, so when I query on local network I am redirected to the local address. But since I have multiple containers I still needed an nginx proxy manager where I have the external url mapped to the local address with the port. Then I have this external address in local DNS in pihole. This is the build for the local network and for me to be able to translate the url to the local address in the local network. Since my ISP does not allow direct querying to their address (isp loop). So I can't directly access my address from outside. Which has complicated things for me quite a bit. Therefore I had to use another server (in this case it suited me well that I have another remote VPS) where I also have a domain. So I created a subdomain for that domain and redirected that domain to the VPS. On the VPS I am running frps which is configured and connects to my home server using fprc. In any case frpc queries the nginx proxy manager which knows the port.

For some reason it seems to me that managing this feature in immich would be much easier than my solution. But I respect your decision.

And now in short.
Local:
Pihole (as local dns) -> nginx proxy manager -> immich container
Remote:
Cloudflare -> remote VPS -> FRPS -> FRPC (on local server) -> nginx proxy manager -> immich container

@imran0
Copy link

imran0 commented May 14, 2023

I too think this feature will be immensely useful. I would greatly appreciate it if the Immich dev's could reconsider this feature request.

@Caian
Copy link

Caian commented Jun 29, 2023

I also think this is super useful. In my case I use Tailscale so I don't have to expose any service through my public IP. Because of this, each service is bound to a different IP, so there is no concept of an external DNS record.

@RyGuy994
Copy link

RyGuy994 commented Jul 4, 2023

Having this out of the box would help me a bunch. I have 6 friends and family that I have set them up with their own server. Mainly for immich. Each time I have to configure a reverse proxy, then go on top of that and establish a local DNS to a second RP. This would cut down on a bunch of man hours.

@Scorcerer
Copy link

Hi!
Having the same wish I wanted to share one angle that I think nobody mentioning yet: the encryption.
As example, please look how HomeAssistant does that: depending if you're on some specific WiFi the app uses url B, and if not it uses url A. They can be completely different, which is very nice, as being at home i don't really need to jump through hoops of setting proper SSL and all of that stuff, since it's local. If I'm away form home (other, not specified WiFi or mobile connection) the app seamlessly chooses SSL-encrypted entry point that has all the security I can provide (In my case, that's whole another server, as I don't get an public IP where my storage is). This is undoable with the proposed DNS approach - the encryption will be there either all the time (problematic locally) or never at all (BAD(tm) thing to do).

Please rethink this, from my non-programmer approach it looks like simple if-then-else, but I'd understand it's maybe not that easy...

@KeeganCarter11
Copy link

KeeganCarter11 commented Sep 29, 2023

I wanted to bump this as well, I was kinda surprised this isn't an option since the other main thing I host is gome assistant and am currently fighting my local dns to get this app set up. External routing is easy, but forcing users to set up a local dns server isn't that user friendly.

@kiwijunglist
Copy link

kiwijunglist commented Nov 4, 2023

I came across this thread looking for a solution.

My situation is that I setup the immich app to point to timescale VPN IP address and wanted a fallback local IP address for when timescale wasn't running.

In home assistant app it supported local IP and remote IP address which was handy.

The DNS server is a good idea, so I will research into running my own DNS server for my local network to point the timescale IP to the local IP.

Thanks again for the app, I love it.

@eded333
Copy link

eded333 commented Dec 17, 2023

This is exactly what the HomeAssistant app does, when you are located at home within your wifi, it uses your internal ip, located elsewhere it uses the external one.
It would be extremely useful and much less of a hassle for people that use a VPN as tailgate to connect home but want to use the local network when at home.
image

@kiwijunglist
Copy link

I initially wrote I was keen on the fallback url option.

Subsequently I have installed wireguard on my unraid server and no longer require this feature. I use the local IP and then when I am not home wireguard automatically kicks in.

@Caian
Copy link

Caian commented Dec 18, 2023

I initially wrote I was keen on the fallback url option.

Subsequently I have installed wireguard on my unraid server and no longer require this feature. I use the local IP and then when I am not home wireguard automatically kicks in.

VPNs are known to drain a lot of battery though.

@kiwijunglist
Copy link

kiwijunglist commented Dec 18, 2023

That is true. Android phone user here, tailscale used some battery, haven't noticed any drain with wireguard. Didn't come up on battery stats.

@jenda69
Copy link

jenda69 commented Dec 21, 2023

This would be really nice feature to have!
I've set up dnsmasq on my router to get local IP in my LAN as suggested in this thread and it somewhat works...
Until I use a device which uses Private DNS (enabled by default on Android I guess). Then it just ignores DNS server provided by DHCP and all the data go over half of Europe through my tunnel again.

I thought I could just check for my home IP address on the server I use as the tunnel and instead of reverse proxying send HTTP redirect to the local IP. That works great when accessing through webbrowser, but Immich app doesn't follow redirects and refuses to work.

@krunkster
Copy link

I think this is going to be a must have feature... eventually.

I'm a fairly technical person, decades of software engineering experience, and I think you've done a great job of making Immich easy to install and use on a local network. Making it accessible remotely (and securely) is an order of magnitude more complicated, and likely beyond most people. Concepts like TLS, reverse proxy, and Split DNS require a lot of technical knowledge. Caddy helps solve the first two, but it's difficult to get right. Pi Hole is a popular way to do local and split DNS but even once it's configured Immich seems to be much slower and more unstable compared to a direct local connection.

I understand the audience of Immich today may be the IT hobbyist, but for wider adoption features like this one will make a big difference in reducing technical overhead for a lot of users.

@Betoniara

This comment was marked as duplicate.

@sneffetsd
Copy link

sneffetsd commented Apr 4, 2024

This is a must. My network is behind a CGNet, I need to use a cloudflare tunnel, what means that I can't upload videos from my mobile gallery. It's not a reality change manually every time when needs to upload an large file, for me that would be easy, but for family members that is not easy to understand (Why don't I just use google photos instead? Is what they ask me).

Home Assistant does that in the settings and it runs seamless.

@shlomiassaf
Copy link

With today's tools this one is a must!

As an example, it's easy today to use zero-trust security to apply a setup free tunnel to a serve(e.g CloudFlare Tunnels without the cumbersome VPN setup.
It does however process traffic (decrypt ssl and encrypt back) so you want to avoid most traffic, especially when home.

For example, my setup is photos.mydomain.local for home network and photos.mydomain.co for external

I would like to use the first on my home network and the external outside.

Both are protected via oidc through my authentik server which will go to google as it's oidc solution so the tunnel provider will never know my password ( it can know my temp tokens and content as it strips down but I trust cloudflare)

Since it's free I wouldn't want to abuse the service and anyway reduce latency and speed things up locally !

This is must, I really don't see how we miss this one.

At least, in the interim allow us to choose a server in the login screen, I need to change the address every time manually

@corgana
Copy link

corgana commented Jun 9, 2024

Any reconsideration on this front? Really would love this feature. As others have said it's great in Home Assistant.

@phil9309
Copy link

Any official update on this feature?

@alextran1502
Copy link
Contributor

@phil9309 not on the priority list at the moment, but probably will be added once we refactor the auth pipeline to solve other issues

@Triple-Z
Copy link
Contributor

Triple-Z commented Jul 2, 2024

As a homelab user, I need this functionality very much. For now I have installed two immich app instances on my mobile phone. One is official and the other one is installed via Xcode for external use (with custom header support via #10588 ).

It would be very glad for me if this feature could be done.

@ampersandru
Copy link

ampersandru commented Jul 15, 2024

Would love this since Im using a reverse proxy + cloudflare proxy and uploads are SLOW at 7 MB/s even when on the same local network. When I log out of the immich app and log back in with the local address of immich, uploads hit 50MB/s and higher

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests