how to configure a NAT to hit nginx inside proxmox host

Juliet

Member
Oct 24, 2023
55
0
6
hi,
i have a k8s cluseter deployed inside a proxmox host.

1723030424659.png

everytime i deploy an app inside the cluster , i make a NodePoer service for it, ex :30001, and in order to access the app outside the cluster using the public IP, i create a NAT rule in proxmox host for that reason like :
Code:
post-up iptables -t nat -A PREROUTING -i vmbr0 -p tcp --dport 30001 -j DNAT --to 172.16.104.107:30001
post-down iptables -t nat -D PREROUTING -i vmbr0 -p tcp --dport 30001 -j DNAT --to 172.16.104.107:30001

now, i have installed an ingress controller inside my cluster and i have deployed an nginx app for test pupose, and i can access from proxmox host :
Code:
curl --header "HOST: nginx.example.com" http://172.16.104.107:30747
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>

where 30747 is number of the nodeport for http ans 30755 for https.

but my problem is asking the user to type the port number each time they want to access our HTTP/(S) is not the best way to go. So, is it possible to dot a nat NAT that look like this:
public IPPortLocal IPPOrt
my public ip80172.16.104.107TCP/30747
my public ip443
172.16.104.107
TCP/30755

i have tested this :

post-up iptables -t nat -A PREROUTING -i vmbr0 -p tcp --dport 80 -j DNAT --to 172.16.104.107:30747
post-down iptables -t nat -D PREROUTING -i vmbr0 -p tcp --dport 80 -j DNAT --to 172.16.104.107:30747
post-up iptables -t nat -A PREROUTING -i vmbr0 -p tcp --dport 443 -j DNAT --to 172.16.104.107:30755
post-down iptables -t nat -D PREROUTING -i vmbr0 -p tcp --dport 443 -j DNAT --to 172.16.104.107:30755

and from the browser when i type : http://244.12.85.96 nothing happens
could you help please ?thanks
 
Last edited:

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!