One IP, two web servers

KingPrawn22

Active Member
Oct 19, 2016
5
0
41
34
Hi all.

I've spend the day trying to get this set-up to no avail. The examples I've found online so far seem geared towards slightly different use cases than my own, which could be the cause of this. I've resorted to starting again from scratch, with a working PVE host.

Now, as the title states, I have 1 public IP address (dynamic, but I'll worry about that later), yet I'd like to have two separate web servers. They host the same application, but the app doesn't support multiple users. A very rough set-up is:

HOST - PVE: 192.168.1.200 (current IP)
- CT1: one.domain.com, IP such as 192.168.0.1 / 10.1.1.1 etc etc. (whatever works)
- CT2: two.domain.com, as above X.X.X.2

The two of them require both port 80 and 443. The general consensus seems to be to use the bridge to assign both containers their unique internal IP, then to have Nginx on the host (pve), direct requests to each one, depending on the subdomain used.

Would anybody be able to point me in the right direction? I do hope to document the process, which I would like to think could help people like myself in the future, so there's some sort of benefit to chipping in if at all possible.

Thank you in advance for any help provided. It is always appreciated.
 
Hi
This will not work.
If you want to host two web servers on the same IP, with the same ports, you should put them on a single container and use VirtualHosting. Google virtual hosting for Nginx and Apache2
 
Ah, I see. That explains a lot!

I am somewhat familiar with virtual hosts, but I thought that the app I'm looking to install can only have one instance per server, and I didn't have any other idea than to install on two separate hosts. Turns out that there's a tool to deploy the app in Docker containers, so I can run multiple instances on the same host.

Thank you for your reply.
 
Ah, I see. That explains a lot!

I am somewhat familiar with virtual hosts, but I thought that the app I'm looking to install can only have one instance per server, and I didn't have any other idea than to install on two separate hosts. Turns out that there's a tool to deploy the app in Docker containers, so I can run multiple instances on the same host.

Thank you for your reply.
My only problem with this, is one webserver with multiple sites up, if something goes wrong and backup is hosed you loose all those sites
 
You can have multiple VMs/LXCs even on multiple PVE nodes with different private IPs that are served by a reverse proxy (like for example HAproxy) using a single public IP on the same port. That reverse proxy then will forward those queries to the different web servers depending on the domain used.
 
Im also interested in this for my home lab, but cannot find any reliable information on how to do this correctly within Proxmox.
 
There are multiple choices:
A.) set up a proxy yourself on CLI using haproxy/nginx/whatever
B.) if you also want a router and stuff like IDS/IPS, VPN, firewall and so on a OPNsense VM might be a good idea which would also offer a plugin for haproxy
C.) if you want some easy to configure webUI to manage your reverse proxy you could set up a VM with docker and roll out a docker container for "Nginx Proxy Manager" or "Traefik Proxy".
 
  • Like
Reactions: oschterhas

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!