This commit is contained in:
nihilist 2025-06-07 09:52:59 +02:00
parent b61c448d96
commit 83c474b59d

99
vpsvpnrouting/index.md Normal file
View file

@ -0,0 +1,99 @@
```
author: Anonymous
date: 2025-01-31
gitea_url: "http://git.nowherejezfoltodf4jiyl6r56jnzintap5vyjlia7fkirfsnfizflqd.onion/nihilist/blog-contributions/issues/320"
xmr: 8AUYjhQeG3D5aodJDtqG499N5jXXM71gYKD8LgSsFB9BUV1o7muLv3DXHoydRTK4SZaaUBq4EAUqpZHLrX2VZLH71Jrd9k8
```
Tutorial: Using a VPS to Route Traffic to a Self-Hosted Service (Hiding Your Home Public IP)
Importance of Hiding Your Home Public IP
Privacy and Security: Exposing your home public IP can lead to potential security risks, including targeted attacks, hacking attempts, and unauthorized access to your home network. By hiding your IP, you reduce the risk of these threats.
Anonymity: When you host services from your home, users can trace back to your home IP address. Using a VPS (Virtual Private Server) allows you to maintain anonymity, making it harder for users to identify your physical location.
Access Control: A VPS can act as a gatekeeper, allowing you to control who accesses your services. You can implement firewalls, VPNs, and other security measures to restrict access.
Performance and Reliability: VPS providers often offer better bandwidth and uptime compared to residential internet connections. This can lead to improved performance for your self-hosted services.
Solution Overview
The solution involves setting up a VPS that acts as a reverse proxy for your self-hosted service. This means that all traffic to your service will go through the VPS, which will then forward the requests to your home server. This way, users will only see the VPS's IP address, not your home IP.
Steps to Complete the Setup
Choose a VPS Provider:
Select a reputable VPS provider (e.g., DigitalOcean, Linode, AWS, or Vultr).
Create an account and choose a plan that fits your needs (consider CPU, RAM, and bandwidth).
Set Up the VPS:
Deploy a new server instance with a Linux distribution (Ubuntu is a popular choice).
Access your VPS via SSH using a terminal or command prompt:
bash
ssh root@your_vps_ip
Install Required Software:
Update the package list and install necessary software (e.g., Nginx or Apache for web services):
bash
sudo apt update
sudo apt install nginx
Configure the Reverse Proxy:
Edit the Nginx configuration file to set up the reverse proxy. Open the configuration file:
bash
sudo nano /etc/nginx/sites-available/default
Add the following configuration, replacing your_home_ip and your_service_port with your actual home IP and service port:
nginx
server {
listen 80;
server_name your_vps_domain_or_ip;
location / {
proxy_pass http://your_home_ip:your_service_port;
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;
}
}
Save and exit the editor.
Test the Configuration:
Test the Nginx configuration for syntax errors:
bash
sudo nginx -t
If there are no errors, restart Nginx to apply the changes:
bash
sudo systemctl restart nginx
Set Up Dynamic DNS (Optional):
If your home IP address changes frequently, consider using a Dynamic DNS service (like No-IP or DuckDNS) to keep your home IP updated.
Install a Dynamic DNS client on your home server to automatically update the DNS records.
Secure Your VPS:
Implement security measures such as setting up a firewall (using UFW or iptables), disabling root login, and using SSH keys for authentication.
Consider setting up HTTPS using Let's Encrypt for secure connections.
Access Your Service:
Now, you can access your self-hosted service through the VPS's domain or IP address. Users will not see your home IP, only the VPS IP.
Conclusion
By following these steps, you can successfully route traffic to your self-hosted service through a VPS, effectively hiding your home public IP. This setup enhances your privacy, security, and control over your services.