Hosting More Than One Thing on Your Home Server? Here's the Noob-Friendly Way!



The Smart Way to Host Multiple Apps: Nginx Reverse Proxy & Docker

Hey fellow home server enthusiasts! So, you've got your Debian 12 box humming along, maybe with Docker running Nextcloud like I do. You've even bravely opened up some ports on your router (high five for that!). But what if you want to host another cool thing, like a Git server for your projects? That's where I was scratching my head too!

Turns out, you don't need to open a whole bunch of new ports. The secret sauce is something called a reverse proxy. Think of it like a super-smart doorman for your server.

Wait, What's a Reverse Proxy?

Imagine you have one main entrance to your apartment building (that's your server's IP address and ports 80/443). Now, inside, you have different apartments (your Docker containers, like Nextcloud and your future Git server). The reverse proxy (in our case, Nginx) stands at the entrance and knows which visitor (request) needs to go to which apartment based on their name (the domain name you type in your browser).

So, when someone types in your-domain.com, Nginx knows to send them to your Nextcloud container. And when they type in git.your-domain.com, Nginx will direct them to your new Git container! Cool, right?

How Do We Make This Magic Happen?

Here’s the basic plan we’ll follow:

  1. Get a New Docker Container: Run your Git service (like Gitea) in its own little Docker world.
  2. Tell the Internet (DNS): Point git.your-domain.com to your server's public IP.
  3. Teach Nginx: Give Nginx instructions to route traffic for your Git subdomain.
  4. Make it Secure: Set up HTTPS with Let's Encrypt for the new subdomain.

1. Deploy the New Docker Container

We'll use Gitea as our Git server. Here’s a clean docker-compose.yml example:

version: '3' services: gitea: image: gitea/gitea:latest container_name: gitea environment: - USER_UID=1000 - USER_GID=1000 volumes: - ./gitea-data:/data ports: - "3000:3000" - "2222:22" restart: unless-stopped

Notice the ports section: - "3000:3000". This means the Git container is listening on port 3000 internally, and we're mapping it to port 3000 on your server itself for Nginx to find it.

2. Update DNS Records

Head over to your domain registrar (Namecheap, Cloudflare, etc.) and add an A record:

  • Host/Name: git
  • Value/Points to: Your server's public IP address
  • TTL: Default

3. Configure Nginx (The Smart Doorman)

Now we tell Nginx how to handle git.your-domain.com. Create a new configuration file at /etc/nginx/sites-available/gitea:

server { listen 80; listen [::]:80; server_name git.your-domain.com;

location / {
    proxy_pass http://localhost:3000;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
}
}

Enable the site and reload Nginx:

sudo ln -s /etc/nginx/sites-available/gitea /etc/nginx/sites-enabled/ sudo nginx -t sudo systemctl reload nginx

4. HTTPS (Making it Secure!)

Run Certbot to grab a new SSL certificate for your subdomain:

sudo certbot --nginx -d git.your-domain.com

Certbot will automatically update your Nginx file to handle the secure port (443) and redirect all HTTP traffic to HTTPS.

That's It!

Now, head over to [https://git.your-domain.com](https://git.your-domain.com) and you should see your brand new Gitea installation! You've successfully expanded your home server's capabilities while keeping your network clean and secure.

Happy hosting! Let me know if you run into any snags – we're all learning here! 😊


Support My Work

If this blog post helped you, please consider a small donation. Your support helps keep this content free and accessible for everyone. Thank you!

Donate with PayPal

The easiest way to support me is by buying me a coffee through PayPal. It's quick, secure, and uses a trusted platform.

Buy Me a Coffee! or a new Macbook!

Donate with Crypto

You can also support me with cryptocurrency. Just copy the address of your preferred coin below.

Bitcoin
31kpUFfNo8SSq5jidTY9Eihyb9qJS4FPP2
Ethereum
0x32fB1E082EB566bBbca3137a5a17a92db9C880F7
XRP
rsRy14FvipgqudiGmptJBhr1RtpsgfzKMM
XRP Tag
3802858062

Comments

Popular posts from this blog

Self-Hosted Personal Cloud: From Old Laptop to Fully Private Cloud

How to Download AnyFlip Books as PDFs with Anyflip Downloader

Mastering WordPress Multisite in cPanel: A Complete Guide