this post was submitted on 21 Oct 2024
26 points (96.4% liked)

Linux

48182 readers
1292 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 5 years ago
MODERATORS
 

Hi there, I will preface this by saying that I'm brand new to server stuff. I have used Linux for a very long time as a personal desktop computer, but not as a server exposed to the internet. I've previously only hosted Minecraft servers for my friends and also once had a VPS for a Discord bot, but otherwise never touched servers.

I've bought a VPS and domain name (let's call it domain.com) and have spun up a Nextcloud instance with it, currently at cloud.domain.com. It's all working smoothly and I'm happy with it.

I wanted to use this VPS to host multiple services. Currently wanting to self-host the following:

  • Mail server
  • Mastodon instance
  • Matrix server
  • Static website (on domain.com)
  • Forgejo instance
  • Possibly other miscellaneous things I might want to put on it, but that's what I'm planning for now

Now this is where the noob question comes in. I want to use this same VPS to host these services, probably as Docker containers, under subdomains like mail.domain.com, mastodon.domain.com, matrix.domain.com, etc, with the root domain being used to host my static website. Is it possible to do this all on one VPS? What about all on one IP address just using different ports? e.g. could I have mastodon.domain.com pointing to the same IP address as cloud.domain.com but just a different port? How do I set up the DNS records to do this?

Currently I have an A record at domain.com pointing to my VPS's IP address (so I can ssh into it with ssh 0v0@domain.com) and a CNAME record at cloud.domain.com pointing to domain.com. This was kind of a complete guess as to how to set this up as this is my first time managing a domain name and I didn't know anything about DNS records before doing this. It seems to work with my current setup of just using the VPS for Nextcloud but obviously I want to do more with this VPS, either that or I'd like to reduce the specs of this VPS to save money as I picked an option that I imagined would be capable of hosting all these things. Is it possible to set up DNS records such that when you connect to subdomain.domain.com it connects you to a specific port? Or is that not something DNS records can do, but I can set up server-side on my VPS?

My VPS provider also lets me buy additional IPv4 addresses for the VPS, if I can't have them on the same IP address with different ports should I buy more IP addresses instead? How do I go about using different IP addresses for the same server?

Or do I need to host these services on completely different VPSes and point towards the different IP addresses with A records?

I've also heard of reverse proxies and that they might be able to achieve this, is this something I should look into or am I barking up the wrong tree here?

I know this question betrays a complete lack of knowledge as to how networking works, so please bear with me. Before someone says "well if you don't know this, you shouldn't be hosting all these services", I have been finding the experience so far (i.e. just having set up my server with Nextcloud) to be fun and educational. I learn best by doing (I have ADHD and struggle with just reading books without doing any exercises alongside it) and I'd like to try host all these services just for the sake of the experience. I'm not hosting anything critical, it is purely for personal projects and I plan to have my friends on my Mastodon and Matrix servers. If this were for something serious I agree I'd get it managed by a professional sysadmin or at least someone who knows what they're doing, but this is just for fun.

I don't need my hand completely held, like I don't need a step by step, but if I could at least be pointed towards concepts/things to research to achieve what I want, I would appreciate that. Literally if I could just be told search terms to look up that would be great, or if you have any more specific pointers than that with specific articles etc even better, or just explain on a high level how I would achieve this setup. Thanks in advance for any help!

TLDR: Is it possible to host these different services on one VPS with one IP address on different ports? If so, how do I set up the DNS records accordingly with my subdomains? If not, how should I achieve hosting these different services on different subdomains, preferably on the same VPS if at all possible?

Edit: Thank you for all the responses, sorry I couldn't give everyone an individual response, but I'm grateful for all the help. I'll look into reverse proxies :) Appreciate it!

you are viewing a single comment's thread
view the rest of the comments
[–] BlackEco@lemmy.blackeco.com 0 points 3 weeks ago* (last edited 3 weeks ago) (1 children)

I'm not familiar with Nextcloud, but from reading the How to use this? section of the README I believe you can run it behind a reverse proxy:

--publish 80:80 This means that port 80 of the container should get published on the host using port 80. It is used for getting valid certificates for the AIO interface if you want to use port 8443. It is not needed if you run AIO behind a web server or reverse proxy and can get removed in that case as you can simply use port 8080 for the AIO interface then.

(Emphasis mine, in "Explanation of the command")

My understanding is you only have to forward traffic from the reverse proxy to the port 8080. It uses a self-signed certificate though, so you might check if the reverse proxy you are using checks certificates signatures for upstream servers.

[–] 0v0@scribe.disroot.org 1 points 2 weeks ago

I wanted to reply just as an update as I finally got round to migrating my Nextcloud instance to be behind nginx, and should anyone else stumble upon this thread maybe this will help you.

I think you misunderstood my question btw but don't worry, I figured it out anyway.

My question was about whether or not I could transfer my Nextcloud instance (including data) to be behind a reverse proxy. The answer is simply yes, you can use the same Docker volumes and it'll be the "same" Nextcloud instance (ie exact same config, user data, etc, no need to set anything up again).

If you've already followed these instructions on a server that doesn't already have a web server running, just take your containers down and follow Nextcloud AIO's reverse proxy guide. If you use the commands suggested in both guides, the volume names will be the same, so the new docker container will use the same volume that the old docker container used. You'll have to delete or rename the old containers so Docker doesn't complain about a container by the same name already existing.