this post was submitted on 27 Dec 2023
30 points (96.9% liked)

Selfhosted

40313 readers
287 users here now

A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don't control.

Rules:

  1. Be civil: we're here to support and learn from one another. Insults won't be tolerated. Flame wars are frowned upon.

  2. No spam posting.

  3. Posts have to be centered around self-hosting. There are other communities for discussing hardware or home computing. If it's not obvious why your post topic revolves around selfhosting, please include details to make it clear.

  4. Don't duplicate the full text of your blog or github here. Just post the link for folks to click.

  5. Submission headline should match the article title (don’t cherry-pick information from the title to fit your agenda).

  6. No trolling.

Resources:

Any issues on the community? Report it using the report flag.

Questions? DM the mods!

founded 1 year ago
MODERATORS
 

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:

homeassistant:
  internal_url: http://192.168.178.214:8123
  external_url: https://ha.xxxxx.duckdns.org

http:
  use_x_forwarded_for: true
  trusted_proxies:
    - 172.22.0.0/24

Following is my Homeassistant Configuration:

  homeassistant:
    container_name: homeassistant
    image: "ghcr.io/home-assistant/home-assistant:stable"
    volumes:
      - /homeassistant/:/config
      - /etc/localtime:/etc/localtime:ro
    restart: unless-stopped
    network_mode: host
    privileged: true
    ports:
      - 8123:8123
      - 5683:5683

  nginx-proxy-manager:
    container_name: nginx
    privileged: true
    image: 'jc21/nginx-proxy-manager:latest'
    ports:
      - '80:80'
      - '81:81'
      - '443:443'
    environment:
      DB_MYSQL_HOST: "nginx-db"
      DB_MYSQL_PORT: 3306
    volumes:
      - /nginx/data:/data
      - /nginx/letsencrypt:/etc/letsencrypt

  nginx-db:
    container_name: nginx-db
    image: 'jc21/mariadb-aria:latest'
    environment:
    volumes:
      - /nginx/mysql:/var/lib/mysql

  vaultwarden:
    container_name: vaultwarden
    image: vaultwarden/server:latest
    restart: unless-stopped
    volumes:
      - /vaultwarden:/data/
    ports:
      - 8125:3012
      - 8124:80
    environment:
      - DOMAIN=https://vw.xxxxx.duckdns.org
      - LOGIN_RATELIMIT_MAX_BURST=10
      - LOGIN_RATELIMIT_SECONDS=60
      - ADMIN_RATELIMIT_MAX_BURST=10
      - ADMIN_RATELIMIT_SECONDS=60
      - ADMIN_TOKEN=
      - SENDS_ALLOWED=true
      - EMERGENCY_ACCESS_ALLOWED=true
      - WEB_VAULT_ENABLED=true
      - SIGNUPS_ALLOWED=true

I have forwarded the ports in the router.

I have set up nginx the following:

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.

all 17 comments
sorted by: hot top controversial new old
[–] MSgtRedFox@infosec.pub 4 points 11 months ago (1 children)

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@lemmy.world 1 points 11 months ago (1 children)

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@infosec.pub 3 points 11 months ago (1 children)

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@lemmy.world 0 points 10 months ago

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.

[–] redcalcium@lemmy.institute 4 points 11 months ago (1 children)

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@lemmy.world 1 points 11 months ago (1 children)

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@lemmy.institute 2 points 11 months ago (1 children)

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@lemmy.world 1 points 10 months ago* (last edited 10 months ago)

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

[–] walden@sub.wetshaving.social 3 points 11 months ago (1 children)

Which ports did you forward?

[–] Lobotomie@lemmy.world 1 points 11 months ago (1 children)
[–] walden@sub.wetshaving.social 4 points 11 months ago (1 children)

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

[–] Lobotomie@lemmy.world 2 points 11 months ago
[–] Decronym@lemmy.decronym.xyz 3 points 11 months ago* (last edited 10 months ago)

Acronyms, initialisms, abbreviations, contractions, and other phrases which expand to something larger, that I've seen in this thread:

Fewer Letters More Letters
DNS Domain Name Service/System
HA Home Assistant automation software
~ High Availability
HTTP Hypertext Transfer Protocol, the Web
IP Internet Protocol
VPN Virtual Private Network
nginx Popular HTTP server

5 acronyms in this thread; the most compressed thread commented on today has 8 acronyms.

[Thread #382 for this sub, first seen 28th Dec 2023, 12:45] [FAQ] [Full list] [Contact] [Source code]

[–] stown@sedd.it 2 points 10 months ago* (last edited 10 months ago) (1 children)

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@sedd.it 2 points 10 months ago (1 children)

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@lemmy.world 1 points 10 months ago* (last edited 10 months ago)

I have set it but it wont change anything. You can access the docker inspect here https://pastebin.com/t1T98RCw I 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).