IPv4 address is becoming rarer by each day. In some cases, it can be pretty hard to get multiple IPv4 address for your Proxmox server.
Thankfully, Proxmox is basically a Debian Linux OS with Proxmox layer on top of that. So that gives us quite a lot of flexibility.
This tutorial will help you to create a fully functional Proxmox server running multiple containers & virtual machines, using only a single IPv4 address.
These are the main steps :
- Create port forwarding rules
- Make sure it’s executed automatically everytime the server is restarted
- Setup a reverse-proxy server : to forward HTTP/S requests to the correct container / virtual machine
- Setup HTTPS
For CT (container) / VM (virtual machine) that contains webserver, point 3 is important – because there’s only one public IP address, so there’s only one port 80 and 443 that’s facing the Internet.
By forwarding port 80 and 443 to a reverse-proxy in a CT, then we’ll be able to forward incoming visitors, by hostname / domain name, to the correct CT/VM.
1. CREATE PORT FORWARDING RULES
Modify the following to match your host’s interface name & CT/VM’s internal IP addresses, then copy-paste to terminal :
###### All HTTP/S traffic are forwarded to reverse proxy iptables -t nat -A PREROUTING -i vmbr0 -p tcp --dport 80 -j DNAT --to 10.10.50.1:80 iptables -t nat -A PREROUTING -i vmbr0 -p tcp --dport 443 -j DNAT --to 10.10.50.1:443 ###### SSH ports to each existing CT/VM iptables -t nat -A PREROUTING -i vmbr0 -p tcp --dport 22101 -j DNAT --to 10.10.50.1:22 iptables -t nat -A PREROUTING -i vmbr0 -p tcp --dport 22102 -j DNAT --to 10.10.50.2:22 iptables -t nat -A PREROUTING -i vmbr0 -p tcp --dport 22103 -j DNAT --to 10.10.50.3:22 iptables -t nat -A PREROUTING -i vmbr0 -p tcp --dport 22104 -j DNAT --to 10.10.50.4:22
Then we save it :
iptables-save > /etc/iptables.rules
2. EXECUTE IPTABLES AT SERVER RESTART
Edit /etc/network/interfaces file, find your network interface name that’s facing the Internet (in my case, vmbr0) – then add the pre-up line as follows :
auto vmbr0
pre-up iptables-restore < /etc/iptables.rules
3. SETUP REVERSE-PROXY
In a CT, install Nginx. Then for each domain, create a configuration file like this, for example: /etc/nginx/sites-available/www.my_website.com :
server {
listen 80;
server_name www.my_website.com;
location / {
proxy_pass http://10.10.50.2:80;
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;
}
}
To activate it (assuming you’re using Ubuntu) link it to /etc/nginx/sites-enabled/ , then restart Nginx :
ln -s /etc/nginx/sites-available/www.my_website.com /etc/nginx/sites-enabled/www.my_website.com /etc/init.d/nginx restart
note: as noted before, all HTTP/s traffic will have to go through this reverse-proxy. You may wish to tune this Nginx installation accordingly.
4. SETUP HTTPS
It’s very easy with Let’s Encrypt once you’ve done point 3 above. Do the following on the reverse-proxy CT :
sudo apt-get update ; sudo apt-get install -y certbot python3-certbot-nginx sudo certbot --nginx sudo /etc/init.d/nginx restart
Reference:
Thanks for sharing nice information. keep up great work
Chord Lagu
media artikel bermanfaat
Great Article. You have beautifully articulated it. Readers revisit only if they found something useful. So the core formula is to provide value to the readers. Also, Title is very important.
Thanks & Regards
thankyou for the information, dont forget to visit
Chord Lagu
Kunci Gitar
Nice info, thanks for share Kopi Terbaik Paid Promote Jual Batu Akik Batik Tulis Video Viral
Nicely Explain Thanks
I recently used the customwritings.com coupon I found on essaypromocodes.net and I was truly blown away by the speed of delivery. I was expecting to receive the essay within the week, but I was pleasantly surprised to find the essay in my inbox within hours. I would highly recommend essaypromocodes.net for anyone looking for a timely essay.
This is my first time pay a quick visit at here and i am really happy to read everthing at one place
Hello i think that i saw you visited my weblog so i came to Return the favore Im trying to find things to improve my web siteI suppose its ok to use some of your ideas
Magnificent beat I would like to apprentice while you amend your site how can i subscribe for a blog web site The account helped me a acceptable deal I had been a little bit acquainted of this your broadcast offered bright clear idea
Somebody essentially lend a hand to make significantly posts I might state That is the very first time I frequented your web page and up to now I surprised with the research you made to create this particular put up amazing Excellent job
I loved as much as you will receive carried out right here The sketch is tasteful your authored subject matter stylish nonetheless you command get got an edginess over that you wish be delivering the following unwell unquestionably come further formerly again as exactly the same nearly very often inside case you shield this hike
I’ve spent over three hours online today and haven’t discovered anything like your article. If all site owners and bloggers wrote like you, the web would be lot more useful.
Its like you read my mind You appear to know a lot about this like you wrote the book in it or something I think that you could do with some pics to drive the message home a little bit but instead of that this is fantastic blog An excellent read I will certainly be back
I do not even know how I ended up here but I thought this post was great I do not know who you are but certainly youre going to a famous blogger if you are not already Cheers
I have been surfing online more than 3 hours today yet I never found any interesting article like yours It is pretty worth enough for me In my opinion if all web owners and bloggers made good content as you did the web will be much more useful than ever before
My brother suggested I might like this blog He was totally right This post actually made my day You can not imagine simply how much time I had spent for this info Thanks
Which hosting service are you using? Could I have your host’s affiliate link? My website loads far slower than yours does. Excellent blog as well.
Wonderful beat I wish to apprentice while you amend your web site how could i subscribe for a blog web site The account aided me a acceptable deal I had been a little bit acquainted of this your broadcast provided bright clear idea
Seeing how much work you put into it was really impressive. But even though the phrasing is elegant and the layout inviting, it seems like you are having trouble with it. My belief is that you ought to try sending the following article. If you don’t protect this hike, I will definitely come back for more of the same.
Hi, I think that I saw you visited my website, thus I came to return the favor. I’m attempting to find things to enhance my site. I suppose it’s ok to use a few of your ideas.
I do not even know how I ended up here but I thought this post was great I do not know who you are but certainly youre going to a famous blogger if you are not already Cheers
What i dont understood is in reality how youre now not really a lot more smartlyfavored than you might be now Youre very intelligent You understand therefore significantly in terms of this topic produced me personally believe it from a lot of numerous angles Its like women and men are not interested except it is one thing to accomplish with Woman gaga Your own stuffs outstanding Always care for it up
I was suggested this web site by my cousin Im not sure whether this post is written by him as no one else know such detailed about my trouble You are incredible Thanks
I’m often to blogging and i really appreciate your content. The article has actually peaks my interest. I’m going to bookmark your web site and maintain checking for brand spanking new information.
Nice blog here Also your site loads up very fast What host are you using Can I get your affiliate link to your host I wish my site loaded up as quickly as yours lol
I do believe all the ideas youve presented for your post They are really convincing and will certainly work Nonetheless the posts are too short for novices May just you please lengthen them a little from subsequent time Thanks for the post
certainly like your website but you need to take a look at the spelling on quite a few of your posts Many of them are rife with spelling problems and I find it very troublesome to inform the reality nevertheless I will definitely come back again
Wow wonderful blog layout How long have you been blogging for you make blogging look easy The overall look of your site is great as well as the content
Hi my family member I want to say that this post is awesome nice written and come with approximately all significant infos I would like to peer extra posts like this
Its like you read my mind You appear to know a lot about this like you wrote the book in it or something I think that you could do with some pics to drive the message home a little bit but instead of that this is fantastic blog An excellent read I will certainly be back
Thank you for the good writeup It in fact was a amusement account it Look advanced to far added agreeable from you However how could we communicate
Family Dollar I appreciate you sharing this blog post. Thanks Again. Cool.