I
Immich•3y ago
raph2960

Trouble setting up immich behind nginx-proxy

Hi, I am trying to add immich as a service to my server. All my services (like nextcloud) are docker-based and use the reverse proxy from here: https://github.com/nginx-proxy/nginx-proxy and I use the letsencrypt docker from here: https://github.com/nginxproxy/acme-companion. I followed the guide and my docker-compose is pretty much the same as the one from the example except that I addes some networks (one local and one for nginx). I tried to follow the procedure to add new services as close as I did for other services. Meaning, I add subdomains to the env files and add services to the reverse proxy network. My docker-compose and env files are attached. However when I try to go to my https://subdomain.my_domain.com that I set in the env file, all I get is a:
{"statusCode":404,"message":"Cannot GET /","error":"Not Found"}
{"statusCode":404,"message":"Cannot GET /","error":"Not Found"}
I get that the docs say to access the website via http and specific port, but the way I understand the reverse proxy is that it forwards requests to the specified subdomain (I specified in the .env file) via https and 443 to the port that the service is internally running on. Any help would be much appreciated!
GitHub
GitHub - nginx-proxy/nginx-proxy: Automated nginx proxy for Docker ...
Automated nginx proxy for Docker containers using docker-gen - GitHub - nginx-proxy/nginx-proxy: Automated nginx proxy for Docker containers using docker-gen
30 Replies
Alex Tran
Alex Tran•3y ago
You only need to reverse proxy back to the vm ip where you host Immich at port 2283 You can leave the most of the .env stuff as default you don't have to change the IMMICH_SERVER_URL at all
Alex Tran
Alex Tran•3y ago
These won't do anything with the Immich server
No description
Alex Tran
Alex Tran•3y ago
So from the default .env.example file just change the DB_PASSWORD. point the UPLOAD_LOCATION to /home/user/photos, and finally changeing the JWT_SECRET You can leave the rest as default IMMICH_SERVER_URL is for the scenario where you don't use Docker
raph2960
raph2960OP•3y ago
Oh okay, hm I tried without that before but never withour the VIRTUAL_HOST stuff, will try right away
Alex Tran
Alex Tran•3y ago
Reverse proxy in on your end, anything that is not in the .env.example is not recognized, therefore won't do anything
raph2960
raph2960OP•3y ago
Wait but if I don't set the virtual_host, how would my reverse proxy know what subdomain redirects to this service?
Alex Tran
Alex Tran•3y ago
So think of immich is a service that is run on port 2283 at the vm ip addresss so from your reverse proxy just redirect the dns back to immich-server-vm-ip:2283 The proxy container you see in the docker-compose file serves the purpose of intenral docker container communication it doesn't related to the reverse proxy you are using to reverse proxy a domain name to the VM/machine that runs Immich what you need to understand is that "Immich is a service that run on the server IP at port 2283"
raph2960
raph2960OP•3y ago
yeah usually this "just works" with whatever port the service is running on. I jus set the virtual host for the service and the reverse proxy proxies. But there is also a VIRTUAL_PORT env var which I will try.
Alex Tran
Alex Tran•3y ago
so from any reverse proxy engine of your choice, just point that dns back to the vm IP at port 2283
raph2960
raph2960OP•3y ago
Okay! I guess I need to ask in the reverse proxy people how I better configure nginx to make it work with immich.
Alex Tran
Alex Tran•3y ago
I use Caddy so I don't have the Nginx reverse proxy config file for Immich but the jist of it is to point what ever domain nameyou have back to "immichserverip:2283" I hope that helps
raph2960
raph2960OP•3y ago
Okay thank you so much!
Alex Tran
Alex Tran•3y ago
Here is my reverse proxy for Caddy šŸ˜›
No description
madkatz
madkatz•3y ago
yeah I use nginx proxy manager, and as @Alex Tran already stated, I didn't have to change anything in the .env file besides the usual (upload location, secret). Then I just pointed my nginx subdomain to localipaddress:2283 and it worked
Alex Tran
Alex Tran•3y ago
simple like so
raph2960
raph2960OP•3y ago
Yeah in the nginx docker I use port and subdomain are defined like I do it above in my env file. https://github.com/nginx-proxy/nginx-proxy#virtual-ports
GitHub
GitHub - nginx-proxy/nginx-proxy: Automated nginx proxy for Docker ...
Automated nginx proxy for Docker containers using docker-gen - GitHub - nginx-proxy/nginx-proxy: Automated nginx proxy for Docker containers using docker-gen
raph2960
raph2960OP•3y ago
But I prob misconfigured something else šŸ™‚ Ah prob because the immich proxy does not make use of the env file at all
Alex Tran
Alex Tran•3y ago
it does but only apply to what we specified, not what nginx-proxy specify have you always use nginx-proxy? maybe try Caddy for simplicity sake? I haven't use Nginx as a container, so my knowledge is quite limited there
raph2960
raph2960OP•3y ago
Hm yeah I have used nginx for a bunch of services, nextcloud, firefly, etherpad, onlyoffice, photoprism. Was never an issue. I don't want to tinker too much with the whole system. (But will look into caddy for sure at some point)
Alex Tran
Alex Tran•3y ago
What is the configuration file of Nginx that you have for Immich?
raph2960
raph2960OP•3y ago
I have none. It is automatic. The only requirement is to start the docker service with a environment variable with the subdomain.
Alex Tran
Alex Tran•3y ago
hmm
raph2960
raph2960OP•3y ago
Hey no worries! It is my weird config, no need for you guys to waste your time on! I will either figure it out or move on šŸ™‚ I really appreciate the time you put into this project!
Alex Tran
Alex Tran•3y ago
sorry Raph, I've never dealt with this configuration namely nginx-proxy container So I am not sure what is the catch here
raph2960
raph2960OP•3y ago
No worries! Thank you for your time! Oh man I'm so stupid, found the error. I have an external network where all services are in it that need to be rerouted by the reverse proxy. And then I usually have an internal network. My mistake was that I only gave the immich-server access to the external network because I initially thought that is the first responder for requests when in reality all I had to do was give the immich-proxy acces to that external network. Now it works
Alex Tran
Alex Tran•3y ago
Nice I am glad you figure it out the hard thing about self-hosting is each person has their own setup šŸ˜›
raph2960
raph2960OP•3y ago
Yeah! I can only imagine which other edge cases come in every week.
jrasm91
jrasm91•3y ago
Sounds like we can update the documentation to make it clearer that immich only exposes a single port (2283) on a single container (immich-proxy) and that any network related configurations should be applied to that ip/service/port.
Alex Tran
Alex Tran•3y ago
Good idea, I originally thinking of making a reverse proxy section but after so many different use-cases, your idea is more applicable
jrasm91
jrasm91•3y ago
We could still do that with some basic examples, but include a big banner somewhere with that info lol

Did you find this page helpful?