Proxying traffic to VMs from one IP

kektagen

New Member
Apr 17, 2022
1
0
1
I've got a bit of a weird setup with my server networking. I have one public IP address, a Proxmox system, and some VMs. All of them need to have specific routing to each other, and I'm using Caddy for this on the main Proxmox machine. This setup is necessary due to only having that one IP and routing everything from there. So my question is, how would I set up Caddy or some other tool to redirect traffic to certain VMs depending on the subdirectory, and more generally TCP/UDP traffic. Any help with this is greatly appreciated.
 
I'm not familiar with Caddy but this is the sort of question that gets asked a lot.

There are two ways to approach this
1. is via custom ip-tables commands in your /etc/network/interfaces file - e.g
Code:
post-up   echo 1 > /proc/sys/net/ipv4/ip_forward
post-up   iptables -t nat -A POSTROUTING -s 172.16.100.0/24 -o ens16 -j SNAT --to-source <public-ip>
post-down iptables -t nat -D POSTROUTING -s 172.16.100.0/24 -o ens16 -j SNAT --to-source <public-ip>
post-up   iptables -t raw -I PREROUTING -i fwbr+ -j CT --zone 1
post-down iptables -t raw -D PREROUTING -i fwbr+ -j CT --zone 1
post-up   iptables -t nat -A PREROUTING -i ens16 -p tcp --dport 80 -j DNAT --to 172.16.100.2:80
post-up   iptables -t nat -D PREROUTING -i ens16 -p tcp --dport 80 -j DNAT --to 172.16.100.2:80

where your virtual machines are on a 172.16.100.0 network and the public-ip is on ens16

2. is via a virtual machine running a firewall/router such as pfSense
1650221587747.png

If you need to host multiple websites behind one public IP you would need additional software such as nginx
https://github.com/nginx
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!