Hi everybody.

How should I setup reverse proxy for my services? I’ve got things like jellyfin, immich a bitwarden running on my Debian server in docker. So should i install something like nginx for each of these also in docker? Or should I install it from repository and make configs for each of these docker services?

Btw I have no idea how to use something like nginx or caddy but i would still like to learn.

Also can you use nginx for multiple services on the same port like(443)?

  • irmadlad
    link
    fedilink
    English
    014 days ago

    I recommend Caddy. It’s very easy to deploy, and configuring it is a snap. This tutorial helped me out a bunch. There is a Docker version of Caddy, tho I have never used it. I figured, Caddy would do better installed on bare metal. I use Caddy in conjunction with Duckdns.org. Caddy also takes care of renewing your certs when it’s time.

    • @WhyJiffie@sh.itjust.works
      link
      fedilink
      English
      013 days ago

      tailscale is not the same as nginx or any reverse proxy, though. I don’t expose anything publicly, but I still wouldn’t stop using a reverse proxy

  • hendrik
    link
    fedilink
    English
    0
    edit-2
    14 days ago

    You’d install one reverse proxy only and make that forward to the individual services. Popular choices include nginx, Caddy and Traefik. I always try to rely on packages from the repository. They’re maintained by your distribution and tied into your system. You might want to take a different approach if you use containers, though. I mean if you run everything in Docker, you might want to do the reverse proxy in Docker as well.

    That one reverse proxy would get port 443 and 80. All services like Jellyfin, Immich… get random higher ports and your reverse proxy internally connects (and forwards) to those random ports. That’s the point of a reverse proxy, to make multiple distinct services available via just one and the same port.

    • @Octavusss@lemm.eeOP
      link
      fedilink
      English
      014 days ago

      And if i wanted to install nginx from debian repo and make the config file for immich docker instance, bitwarden dcoker instance… how would the config files and ssl certificates for nginx look like?

      • hendrik
        link
        fedilink
        English
        0
        edit-2
        14 days ago

        Maybe have a look at https://nginxproxymanager.com as well. I don’t know how difficult it is to install since I never used it, but I heard it has a relatively straight-forward graphical interface.

        Configuring good old plain nginx isn’t super complicated. It depends a bit on your specific setup, though. Generally, you’d put config files into /etc/nginx/sites-available/servicexyz (or put it in the default)

        server {  
            listen 80;  
            server_name jellyfin.yourdomain.com;  
            return 301 https://$server_name$request_uri;  
        }  
        
        server {  
            listen 443 ssl;  
            server_name jellyfin.yourdomain.com;  
        
            ssl_certificate /etc/ssl/certs/your_ssl_certificate.crt;  
            ssl_certificate_key /etc/ssl/private/your_private_key.key;  
            ssl_protocols TLSv1.2 TLSv1.3;  
            ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384';  
            ssl_prefer_server_ciphers on;  
            ssl_session_cache shared:SSL:10m;  
        
            location / {  
                proxy_pass http://127.0.0.1:8096;  
                proxy_http_version 1.1;  
                proxy_set_header Upgrade $http_upgrade;  
                proxy_set_header Connection 'upgrade';  
                proxy_set_header Host $host;  
                proxy_cache_bypass $http_upgrade;  
            }  
        
            access_log /var/log/nginx/jellyfin.yourdomain_access.log;  
            error_log /var/log/nginx/jellyfin.yourdomain_error.log;  
        }  
        

        It’s a bit tricky to search for tutorials these days… I got that from: https://linuxconfig.org/setting-up-nginx-reverse-proxy-server-on-debian-linux

        Jellyfin would then take all requests addressed at jellyfin.yourdomain.com and forward that to your Jellyfin which hopefully runs on port 8096. You’d use a similar file like this for each service, just adapt them to the internal port and domain.

        You can also have all of this on a single domain (and not sub-domains). That’d be the difference between “jellyfin.yourdomain.com” and “yourdomain.com/jellyfin”. That’s accomplished with one file with a single “server” block in it, but make it several “location” blocks within, like location /jellyfin

        Alright, now that I wrote it down, it certainly requires some knowledge. If that’s too much and all the other people here recommend Caddy, maybe have a look at that as well. It seems to be packaged in Debian, too.

        Edit: Oh yes, and you probably want to set up Letsencrypt so you connect securely to your services. The reverse proxy would be responsible for encryption.

        Edit2: And many projects have descriptions in their documentation. Jellyfin has documentation on some major reverse proxies: https://jellyfin.org/docs/general/post-install/networking/advanced/nginx

      • walden
        link
        fedilink
        English
        014 days ago

        That question is a little bit out of the scope of a forum like this. A question like that would better be answered by the nginx documentation. Sometimes the project documentation might have a blurb about nginx configuration specific for that project. For example, Immich.

        For the most part, you only have to reference the nginx documentation. I’ve never looked at the Immich config above until now, and my Immich server works great.

        I’ve had a reverse proxy for years, but the config files are very foreign to me because I use Nginx-Proxy-Manager. NPM makes nginx usable for dummies like me, at the expense of gaining a deeper understanding of how it works. I’m ok with that, but you might feel differently.

  • @Zwrt@lemmy.sdf.org
    link
    fedilink
    English
    012 days ago

    I know this is beyond the scope of your question but you are at a very similar place like i was over a year ago.

    For the reverse proxy you want ingnx manager and it will handle all of your reverse proxies just fine.

    But what i really want to recommend is to change up that debian into proxmox,

    Proxmox is a debian based efficient server OS. Basically every service you run now can Easily be run as its own isolated container with very little overhang.

    Best of all there is a community for Helper script that will install entire services including Nginx but even nextcloud from a single command.

    https://community-scripts.github.io/ProxmoxVE/scripts?id=nginxproxymanager

    • @Octavusss@lemm.eeOP
      link
      fedilink
      English
      012 days ago

      Thx I appreciate the input. I have already a lot of things set up on the server and switching now would be painful and time consuming. I also use docker in conjunction with kvm-qemu and had I known about proxmox a month ago I would not have construct it at such but alas. I will however in the future get another hardware which I will use as a home server and I will definitely give proxmox a shot.

      Unrealted but Alpine Linux is based af!

  • ippocratis
    link
    fedilink
    English
    014 days ago

    While using a web server before your self hosted micro services is the obvious answer and caddy the easier to configure, as a beginner you should also consider taiscale funnels. You dont need to mess with router stuff like port forward or caring if you ISP have your router behind a cgnat which is kinda norm nowadays , also dont have to care for a domain name dynamic DNS stuff . You could have a look to my quick how to . All you need is running a script , the ports and desired names of your subdomains and your tailscale auth key. https://ippocratis.github.io/tailscale/

    • @Octavusss@lemm.eeOP
      link
      fedilink
      English
      013 days ago

      Well I already got static IP from my ISP and configured Wireguard on my directly on my router so I think I’m good.

      • ippocratis
        link
        fedilink
        English
        013 days ago

        The funnel exposes your local services to the public over https . Like what you want to accomplish with reverse proxy . Its just more straightforward for a beginner.

        Personally I closed my router ports and switched to tailscalr funnels after using caddy with mutual TLS for years.

        • @CapitalNumbers@lemm.ee
          link
          fedilink
          English
          013 days ago

          maybe silly question but does tailscale tunnel operate in a similar fashion to a cloud flare tunnel? as in you can remotely access your internal service over https?

        • @WhyJiffie@sh.itjust.works
          link
          fedilink
          English
          013 days ago

          The funnel exposes your local services to the public over https . Like what you want to accomplish with reverse proxy .

          they did not say they want it public, and that’s an additional security burden they may not need

          • ippocratis
            link
            fedilink
            English
            0
            edit-2
            13 days ago

            He he didnt but thats what he meant

            I mean 99% of users use reverse proxy for https public access

            Also read the threat replies …

            That’s what this thread is about

            No?

            • @WhyJiffie@sh.itjust.works
              link
              fedilink
              English
              012 days ago

              if that’s true, I assume it is because they don’t know about the security consequences, nor about more secure ways. and for 99% that is the worst solution, because they won’t tighten security with a read only filesystem, DMZ and whatnot, worse, they won’t be patching their systems on schedule, but maybe in a year.

              99% users should not expose any public services other than wireguard or something based on it. on a VPS the risk my be lower, but on a home network, hell no!

              • ippocratis
                link
                fedilink
                English
                012 days ago

                Ok I’m not any networking expert but I think you are overestimating the risk here.

                Opening a port doesn’t mean you are opening your whole home network just the specific services you want. And those not directly but with a web server in front of them . Web servers talked in this tgread that sit in front of open ports are well audited . I think that measures like mtls a generic web server hardening are more than ok to not ever be compromised.

                But yeah I’m surely interested to listen if you could elaborate.

                Thanks

    • @WhyJiffie@sh.itjust.works
      link
      fedilink
      English
      013 days ago

      my last experience with it was a half empty documentation, and a config structure that signaled to me that they dropped a lot of features for v2 release that they initially wanted to have, which has additionally made understanding their config structure harder. and that hasn’t improved for years.

  • Agosagror
    link
    fedilink
    English
    014 days ago

    Since your a beginner, youll find nginx proxy manager easiest, it has a nice ui, and at this stage you are probably less intrested in the 10/10 fastest lighweight setup and more intrested in getting stuff working.

    • Flamekebab
      link
      fedilink
      English
      0
      edit-2
      14 days ago

      Yeah, another vote for Caddy. I’ve run nginx as a reverse proxy before and it wasn’t too bad, but Caddy is even easier. Needs naff-all resources too. My ProxMox VM for it has 256 MB of RAM!

    • @Octavusss@lemm.eeOP
      link
      fedilink
      English
      014 days ago

      I’ll definitely take a look at so thx. Also I’m using duckdns right now so i didn’t need to port forward anything but if I use my domain do i need to port forward ports 80&443 from through my router to my debian server (192.168.200.101)?

      • @WhatAmLemmy@lemmy.world
        link
        fedilink
        English
        014 days ago

        You can also choose a mesh vpn like tailscale and then you don’t have to worry about ddns or port forwarding at all, ace you can still use a reverse proxy.

        • @Octavusss@lemm.eeOP
          link
          fedilink
          English
          014 days ago

          I mean i have a wireguard on my router but how can I point the domain from my provider like (godaddy) to my server without opening ports?

      • walden
        link
        fedilink
        English
        014 days ago

        To access things outside of your LAN (for example from your phone while at the grocery store), each service gets a DuckDNS entry. “service.myduckdns.com” or whatever.

        Your phone will look for service.myduckdns.com on port 443, because you’ll have https:// certificates and that all happens on port 443.

        When that request eventually gets to your router and is trying to penetrate your firewall, you’ll need 443 open and forwarded to your Debian machine.

        So yes, you have it right.

        Also forward port 80.

  • Sean
    link
    fedilink
    English
    014 days ago

    I prefer doing nginx on the host (vs a container), & have different configs for each service. You can have multiple services on the same port, it can be controlled via DNS instead (i.e.: access Jellyfin.domain.com & bitwarden.domain.com, both of 443).

    Ive tried Caddy once or twice but couldn’t get it working, so i just stick with nginx & cert or to automatically get certificates from my internal CA

    • @Octavusss@lemm.eeOP
      link
      fedilink
      English
      014 days ago

      Yeah but when I last tried nginx on my bitwarden host and another on my jellyfin host i could access the one for bitwarden on port 81 of my server but couldn’t access the other nginx web page on port 85 even though i have written it in docker compose file and the port 85 was also open on my server.

      • Sean
        link
        fedilink
        English
        014 days ago

        It looks like jhdeval mentioned this already, but you may need to review your config file. By default, you would likely have nginx listening on ports 80 & 443 for requests to a specific address (i.e.: jellyfin.domain.com) which would be configured in your DNS, & then nginx would direct the jellfin 443 traffic to port 85 to access Jellyfin. Same principle for Bitwarden. If you have your nginx config files, i \ we could take a look & see if we spot any issues.

        • @Octavusss@lemm.eeOP
          link
          fedilink
          English
          014 days ago

          I’m currently cannot post it here and also since it didn’t work the first time I’m using only http for jellyfin and immich but i can later post the docker config for bitwarden.

    • Avid Amoeba
      link
      fedilink
      English
      014 days ago

      I’m doing the same with Apache in a container. Using Let’s Encrypt with DNS challenge for SSL certificate. The DNS records point to the reverse proxy IP which is only accessible via VPN (Tailscale). 😂

      • Sean
        link
        fedilink
        English
        014 days ago

        nginx + certbot \ acme for certs from my local Step-CA, proper DNS & I just use a WireGuard VPN on-demand for when I leave my house. As soon as I’m off my Wi-Fi I have the VPN active so I don’t need to expose anything more than 1 port for that to work =]

        I might look at Tailscale, if only because I’ve seen plenty of people say that’s how they connect, so worth looking into =]

        • Avid Amoeba
          link
          fedilink
          English
          0
          edit-2
          14 days ago

          If you want to stay fully self-hosted, look into Headscale. You could run it locally with a port open, or you could throw it on the tiniest cloud VM somewhere and have zero ports open at home.

  • @iAmTheTot@sh.itjust.works
    link
    fedilink
    English
    014 days ago

    Nginx Proxy Manager was easy to learn as a beginner. I’d recommend it as a learning tool, if nothing else, and if you want to switch to other solutions later you can.

  • @yaroto98@lemmy.org
    link
    fedilink
    English
    014 days ago

    A lot of people aren’t big fans of Nginx Proxy Manager, which is separate from Nginx. But I like it. It’s got a nice gui, and the part I really like is the letsencrypt ssl certs baked in. You can get a new one, for a new service with a click of a button, and it auto renews your certs, so you don’t have to worry about it once it’s set up.

  • @ohshit604@sh.itjust.works
    link
    fedilink
    English
    014 days ago

    Reverse proxying was tricky for me, I started with Nginx Proxy Manager and it started out fine, was able to reverse proxy my services in the staging phase however, once I tried to get production SSL/TLS certificates it kept running into errors (this was a while ago I can’t remember exactly) so that pushed me to SWAG and swag worked great! Reverse proxying was straight forward, SSL/TLS certificates worked well however, overall it felt slow, so now I’m using Traefik and so far have no complaints.

    It’s honestly whatever works for you and what you prefer having.

  • @Zozano@aussie.zone
    link
    fedilink
    English
    0
    edit-2
    14 days ago

    IMO, look into the linuxserver.io fork of NGINX, called SWAG.

    It comes preloaded with a bunch of fantastic addons for security.

    Quite easy to get set up, if you’ve got an idea about how it works.

  • 👍Maximum Derek👍
    link
    fedilink
    English
    014 days ago

    I use Nginx Proxy Manager running as a docker container. Its a gui that makes administration more straight forward. It points at all my services (docker and otherwise) and handles the SSL for me. Because I don’t want to have any ports open I use DNS challenge ACME and NPM has build in support for a number APIs from large public DNS providers to automate that.

    • @CapitalNumbers@lemm.ee
      link
      fedilink
      English
      013 days ago

      i have nginx proxy manager set up all as well, but haven’t worked out the SSL part yet, so all my internal docker services are still on http

      out of interest, how did you set up https with npm?

      • 👍Maximum Derek👍
        link
        fedilink
        English
        0
        edit-2
        13 days ago

        First set up your certificate in the SSL tab of NPM. You can either upload a traditional certificate or set up LetsEncrypt. Be aware that starting next spring the maximum length of a certificate will drop to 9 months and continue to decrease over the next few years until its 47 days.

        I have mine set up so LetsEncrypt gets a wildcard cert for my domain (via DNS challenge). Some people go with per subdomain certs.

        Once you have the cert, go you each of your hosts and switch to its SSL tab. Then select your cert. Then I usually turn on “Force SSL”

        • @CapitalNumbers@lemm.ee
          link
          fedilink
          English
          012 days ago

          does a wild card cert essentially mean i have use one cert which will cover all my subdomains as well as the primary domain?