Self Hosting on your Home Server - Cloudflare + Nginx Proxy Manager - Easy SSL Setup
Table of Contents
Introduction
This tutorial will guide you through the process of self-hosting applications on your home server using Cloudflare and Nginx Proxy Manager. You'll learn how to set up a secure environment for your projects, ensuring they are accessible and safe. By following these steps, you can effectively manage web traffic and SSL certificates with ease.
Step 1: Understand Prerequisites
Before diving into the setup, ensure you have the following:
- A home server running a compatible operating system (Linux-based is preferred).
- Docker installed on your server for easier application management.
- Basic knowledge of command line operations.
Step 2: Set Up a Reverse Proxy
A reverse proxy is essential for managing incoming requests and directing them to the correct service. Here's how to set it up:
- Install Docker if you haven't already. You can usually find installation instructions on the official Docker website.
- Pull the Nginx Proxy Manager image using the following command:
docker pull jc21/nginx-proxy-manager
- Run the Docker container with the necessary configurations. Use the command below, modifying the environment variables as needed:
docker run -d \ -p 80:80 \ -p 443:443 \ -e DB_SQLITE_FILE=/data/database.sqlite \ -v /path/to/your/data:/data \ --restart always \ --name nginx-proxy-manager \ jc21/nginx-proxy-manager
Step 3: Open Required Ports
For your reverse proxy to function correctly, you must open the appropriate ports on your router:
- Port 80 for HTTP traffic.
- Port 443 for HTTPS traffic.
- Refer to your router's manual for specific instructions on how to open these ports.
Step 4: Configure Cloudflare
Using Cloudflare enhances your server's security and performance. Follow these steps:
- Create a Cloudflare account or log in to your existing account.
- Add your domain to Cloudflare by following the prompts.
- Update your domain's nameservers to point to Cloudflare's nameservers as instructed.
Step 5: Set Up Nginx Proxy Manager
After configuring Cloudflare, set up Nginx Proxy Manager:
- Access the Nginx Proxy Manager interface by navigating to your server's IP address in a web browser.
- Log in using the default credentials:
- Email: admin@example.com
- Password: changeme (Make sure to change this after your first login).
- Create a new proxy host:
- Go to "Proxy Hosts" and click on "Add Proxy Host."
- Fill in your domain and the internal address of the service you want to expose.
Step 6: Configure Cloudflare SSL/TLS Settings
To ensure secure connections, configure the SSL/TLS settings in Cloudflare:
- Go to the SSL/TLS section in your Cloudflare dashboard.
- Set the SSL option to "Full" or "Full (strict)" for enhanced security.
- Enable "Always Use HTTPS" to redirect all HTTP requests to HTTPS.
Step 7: Test Your Setup
After completing the configurations:
- Access your domain through a web browser.
- Verify that the connection is secure (look for the padlock icon in the address bar).
- Check that your applications are reachable and functioning as expected.
Conclusion
You've successfully set up a self-hosted environment using Cloudflare and Nginx Proxy Manager. This configuration not only secures your applications but also simplifies management of SSL certificates. As a next step, consider exploring additional features of Nginx Proxy Manager, such as automated SSL certificate renewals and advanced access controls.