this post was submitted on 24 Feb 2025
15 points (100.0% liked)

Selfhosted

42858 readers
2177 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 2 years ago
MODERATORS
 

I have a few things that I host from my house. I have read that it's better practice to route stuff through a VPS to not expose your home IP.

Here's what I've done so far: VPN setup on VPS with successful routing of containers. Confirmed by using a CLI IP check within the container which returned the VPS IP. I used PiVPN because I know it and it's easy to set up.

Where I got stuck: I pointed Nginx to the supposed IP:port of the connection, but couldn't get it to load.

What should I do next?

you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 1 points 15 hours ago* (last edited 15 hours ago) (2 children)

Nginx was already set up and working before. I have some sites hosted directly on the VPS as well.

I'm just not sure how to make a http request go to a VPN client

[–] [email protected] 1 points 8 hours ago

By using its ip:port

If you have homeserver1 running stuff and that’s connected to the vps through vpn you make sure your homeserver1 service that you want to proxy runs on the homeserver1’s vpn ip.

For docker this is done by specifying that ip when you expose ports or use 0.0.0.0

I assume you can already ping homeserver1 from the vps by using the vpn address of homeserver1

[–] 69420 5 points 14 hours ago

Assuming your local service is accessible from the nginx server, you can proxy the request to it:

server {
  listen 80;
  location / {
    proxy_pass http://10.100.100.2:3000/;
  }
}

...where 10.100.100.2 is your local IP on the VPN and 3000 is the local port your service is listening on, and 80 is the public port your nginx server listens on. Everything that hits your nginx server at http://yourserver.com:80/ will proxy back to your local service at http://10.100.100.2:3000/. Depending on what you're hosting, you may need to add some things to the config.