Help needed setting up NGINX reverse Proxy / HA / Vaultwarden using Duckdns

Hey Guys,

so I still have no clue about most of the stuff im doing hence why I am doing it :)

I have a ubuntu system running all kinds of docker containers and I want to expose homeassistant and vaultwarden to the internet.

Now I have set up a Duckdns account, I have setup my Router (fritzbox) to update the dyndns settings, I have set up my homeassistant the following:


<span style="color:#323232;">homeassistant:
</span><span style="color:#323232;">  internal_url: http://192.168.178.214:8123
</span><span style="color:#323232;">  external_url: https://ha.xxxxx.duckdns.org
</span><span style="color:#323232;">
</span><span style="color:#323232;">http:
</span><span style="color:#323232;">  use_x_forwarded_for: true
</span><span style="color:#323232;">  trusted_proxies:
</span><span style="color:#323232;">    - 172.22.0.0/24
</span>

Following is my Homeassistant Configuration:


<span style="color:#323232;">  homeassistant:
</span><span style="color:#323232;">    container_name: homeassistant
</span><span style="color:#323232;">    image: "ghcr.io/home-assistant/home-assistant:stable"
</span><span style="color:#323232;">    volumes:
</span><span style="color:#323232;">      - /homeassistant/:/config
</span><span style="color:#323232;">      - /etc/localtime:/etc/localtime:ro
</span><span style="color:#323232;">    restart: unless-stopped
</span><span style="color:#323232;">    network_mode: host
</span><span style="color:#323232;">    privileged: true
</span><span style="color:#323232;">    ports:
</span><span style="color:#323232;">      - 8123:8123
</span><span style="color:#323232;">      - 5683:5683
</span><span style="color:#323232;">
</span><span style="color:#323232;">  nginx-proxy-manager:
</span><span style="color:#323232;">    container_name: nginx
</span><span style="color:#323232;">    privileged: true
</span><span style="color:#323232;">    image: 'jc21/nginx-proxy-manager:latest'
</span><span style="color:#323232;">    ports:
</span><span style="color:#323232;">      - '80:80'
</span><span style="color:#323232;">      - '81:81'
</span><span style="color:#323232;">      - '443:443'
</span><span style="color:#323232;">    environment:
</span><span style="color:#323232;">      DB_MYSQL_HOST: "nginx-db"
</span><span style="color:#323232;">      DB_MYSQL_PORT: 3306
</span><span style="color:#323232;">    volumes:
</span><span style="color:#323232;">      - /nginx/data:/data
</span><span style="color:#323232;">      - /nginx/letsencrypt:/etc/letsencrypt
</span><span style="color:#323232;">
</span><span style="color:#323232;">  nginx-db:
</span><span style="color:#323232;">    container_name: nginx-db
</span><span style="color:#323232;">    image: 'jc21/mariadb-aria:latest'
</span><span style="color:#323232;">    environment:
</span><span style="color:#323232;">    volumes:
</span><span style="color:#323232;">      - /nginx/mysql:/var/lib/mysql
</span><span style="color:#323232;">
</span><span style="color:#323232;">  vaultwarden:
</span><span style="color:#323232;">    container_name: vaultwarden
</span><span style="color:#323232;">    image: vaultwarden/server:latest
</span><span style="color:#323232;">    restart: unless-stopped
</span><span style="color:#323232;">    volumes:
</span><span style="color:#323232;">      - /vaultwarden:/data/
</span><span style="color:#323232;">    ports:
</span><span style="color:#323232;">      - 8125:3012
</span><span style="color:#323232;">      - 8124:80
</span><span style="color:#323232;">    environment:
</span><span style="color:#323232;">      - DOMAIN=https://vw.xxxxx.duckdns.org
</span><span style="color:#323232;">      - LOGIN_RATELIMIT_MAX_BURST=10
</span><span style="color:#323232;">      - LOGIN_RATELIMIT_SECONDS=60
</span><span style="color:#323232;">      - ADMIN_RATELIMIT_MAX_BURST=10
</span><span style="color:#323232;">      - ADMIN_RATELIMIT_SECONDS=60
</span><span style="color:#323232;">      - ADMIN_TOKEN=
</span><span style="color:#323232;">      - SENDS_ALLOWED=true
</span><span style="color:#323232;">      - EMERGENCY_ACCESS_ALLOWED=true
</span><span style="color:#323232;">      - WEB_VAULT_ENABLED=true
</span><span style="color:#323232;">      - SIGNUPS_ALLOWED=true
</span>

I have forwarded the ports in the router.

I have set up nginx the following:

https://lemmy.world/pictrs/image/534b7ad1-c10d-42a8-9da4-90e2aac4c67f.png

Issue is when I open the website, it will give me the error that hsts is enabled, even though I definitely did not check this option ( and I never did (today!).

What is the reason for this?

Do I have to set some sort of header?

Same thing with vaultwarden, basically I set this up 1:1 except for the url whichi is vw.xxxxx.duckdns .org.

MSgtRedFox,
@MSgtRedFox@infosec.pub avatar

What cert did you put on the proxy answering the inbound? Usually that error means either the browser doesn’t like the cert, or it’s connecting to 80, and modern browsers really fight you on that sometimes. Also, cache. Clear your cache if you’re bouncing between internal URL/IP and the public.

I assume you just want to expose to internet to learn art of reverse. Otherwise there’s better ways.

Lobotomie,

Mainly I want to expose it so I can access my stuff remotely. What would you recommend otherwise? Traefik looks alot more difficult to me from the get go but I haven’t tried it out yet (because I dont know where to start) Issue is just that I have a basic understanding about docker/ubuntu stuff now (or I know how to manipulate stuff like I want) but basically everything with Web and https is a big black hole for me which I can’t seem to grasp yet.

MSgtRedFox,
@MSgtRedFox@infosec.pub avatar

Yeah, it’s a lot. It’s a very large field, and you’re playing in two or three areas here.

Look at a couple of overlay options. ZeroTier is the one I remember off top of my head. There are others, Google alternatives. These use a coordination server. Some are a hosted service, but there’s some that you host yourself. These are supposed to be pretty easy. You watch a couple of videos on these, I bet you’re be fine.

Wire guard offers more traditional VPN. You can tunnel your device back to your network. Some routers offer a VPN option. There’s open sense, ddwrt, etc. Again, lots of videos.

Since you said you mostly wanted remote access, I strongly suggest not opening services to public and use VPN.

You can still learn reverse proxy too, but just do it internally, even though it wouldn’t technically be needed. This will be much safer and learner friendly.

I have ridiculous amounts of services running, but I use gateway router VPN to access most of them.

Lobotomie,

using a vpn or similar is not really an option as I have famiy members accessing it and I dont want to always connect using a vpn just for example to open my garage or accessing my shopping list. Security wise I just use 2FA so I dont think thats the issue.

walden,

Which ports did you forward?

Lobotomie,

80,443,8123 and 8124

walden,

Only 80 and 443 get forwarded to nginx. nginx handles everything from there. Close the other ports.

Lobotomie,

cheers!

redcalcium,

What happened when you tried to open it on incognito mode / private browsing mode?

Btw, if you’re using Chrome, you can type thisisunsafe to bypass hsts warning if nothing else work.

Lobotomie,

if I close the 8123 port and remove my cache, firefox will warn me, if I click on forward anyways it will forward to a website from my router for some reason saying that the DNS-Rebind-Protection has blocked my attempt and that there is some issue with the host-header.

redcalcium,

Instead of forwarding ha.yourdomain.com to 192.168.178.214 (which I assume is the lan ip address for your machine), you should forward it to a hostname called homeassistant (which is the hostname for the home assistant instance inside your docker compose network).

Lobotomie, (edited )

Now I get a error Fehlercode: SEC_ERROR_UNKNOWN_ISSUER, and if I continue it will again go to my router with the DNS-REbind / Host-Header Issue

stown, (edited )
@stown@sedd.it avatar

Are you absolutely sure that NPM has an IP from the subnet 172.22.0.0/24? Is there any way you can remove the trusted_proxies setting from homeassistant and then check if it will accept the connection from NPM?

stown,
@stown@sedd.it avatar

I did some reading and found that the trusted_proxies setting is required. Can you try setting it to 0.0.0.0/0?

Lobotomie, (edited )

I have set it but it wont change anything. You can access the docker inspect here pastebin.com/t1T98RCwI can imagine that this problem is before homeassistant as even if I ignore the certificate error , it will not forward me to homeassistant but to my router / a warning page from my router saying it has blocked me.

If I test the server reachability inside nginx manager it will ask me if npm is configured correctly, so you might be onto something with NPM configuration …

I have now set up duckdns over docker instead of over my router, but it hasnt helped anything. My Duckdns IP is the same (and its correct, if I just open this IPV4 Address it will redirect to my nginx landing page).

Okay I think here is the error. AFter doing the Test Server Reachability the following will come up in the nginx-db logs: 2023-12-29 21:06:25 3 [Warning] Aborted connection 3 to db: ‘npm’ user: ‘npm’ host: ‘172.22.0.8’ (Got an error reading communication packets)

Now I have no clue why this is ( I think this is the end for today as my head is about to explode). Docker inspect nginx reveals that this request for sure came from nginx (as it has the .0.8 ip).

  • All
  • Subscribed
  • Moderated
  • Favorites
  • selfhosted@lemmy.world
  • localhost
  • All magazines
  • Loading…
    Loading the web debug toolbar…
    Attempt #