How to setup cPanel when using Floating IP ?

Posted December 2, 2015 8.9k views
CentOSDNSControl Panels

I am using one droplet with CentOS and WHM/cPanel installed on them. Also I assigned a Floating IP to that droplet. In WHM i created two accounts for my two domains. At the registrar I pointed them to the digitalocean NS servers. In the domain section of digitalocean I created entries for the two domains. Both of the domains respond at ping requests from the floating IP. The problem is that when I try to access the domain by http I land on the cgi-sys/defaultwebpage.cgi page.
Please if you could tell me what further settings must I operate in WHM so that both of my domains work.
Thank you in advance.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
9 answers


If this is only a single server setup, using a floating IP address really isn’t going to do much or make a configuration any more reliable. It’d be better to utilize the primary IP address of the Droplet and not tie domains to an IP that isn’t meant to be used as a dedicated IP for your Droplet.

The purpose of a floating IP is to simplify HA (High-Availability) setups by allowing you to switch from one server to another in the event of downtime. The issue here is that, if you don’t have a system in place to make this switch (i.e. API integration with DigitalOcean’s API), nothing will happen and if the Droplet is down, it’s still down (just as it would be on the primary Public IP).

For this solution to effectively work, you’d need a second server setup (thus requiring a second cPanel license) which replicates data from the primary near-instantly. If you were to separate web & database (thus 2 Droplets), then you’d ideally need 4 droplets (still 2 cPanel licenses as the database servers do not require a cPanel license for this particular type of setup) as you don’t want to be stuck in a position where your web servers are up but your sole database server is down (which can happen).

Additionally, you would realistically need 1-2 more Droplets acting as proxies, thus telling traffic where to go (and, of course, to monitor the “health” of your two web servers and two database servers, thus preventing traffic from being sent to a downed server).

That said, if you do choose such a path, the second server would need to be identical to your primary (and this isn’t a native feature for cPanel, so you’d have to setup mirroring and ensure that all aspects are replicated over, including any changes that cPanel makes such as updates, upgrades, config etc).

That said, cPanel uses Bind last I recall, so the DNS Zone for Bind (which can be modified through WHM) needs to be a mirror of your DNS zone for DigitalOcean, so you’d need to make sure that the NS, A, CNAME, TXT and all other DNS records match 1-for-1.

You would also need to verify the IP’s for each domain on the cPanel server. Since cPanel will, in most cases, auto-configure to the primary IP of the server it’s installed on (which wouldn’t be the floating IP), if you’re trying to use the floating IP when it’s assigning the Public IP to domains, then you’re going to run in to issues there.

@jtittle I wish to thank you for the detailed answer. The scenario wrote by you is describing the professional approach to the problem. I managed to bind the two websites hosted by the server to the floating IP and now everything works perfect.

I found another solution using CP NAT

Run /scripts/build_cpnat and then it will map the floating IP to the internal DO IP your server has configured.

Once that is done, sites are configured through cPanel using the floating IP.
Apache will configure the vhost to listen on the internal IP.
DNS will be setup using the floating IP.
I’m assuming other services will be configured automatically as needed.

This allows it all to work quite smoothly.
In the end all the client sites point to the floating IP. DNS records point there, all traffic flows through it.
The server gets the traffic.

Then, if I resize the server, setup a staging server I want to swap for the live server, anything, I can just point that floating IP to the new Droplet. Nice.

Example shell output below.
After this I went into cPanel, changed the default ipv4 IP in the basic setup, and then changed some site IPs to the floating IP.

# = Regular Digital Ocean External IP (not the floating IP)
# = Floating IP
# = Internal IP that server has setup which maps to floating IP.

[root@cp1 network-scripts]# /scripts/build_cpnat
info [build_cpnat] =>
info [build_cpnat] =>

# Now login to cPanel and re-assign site IPs as needed.
  • Now login to cPanel and re-assign site IPs as needed. << unassign ip and re-assign again?

    i need floating ip just for dedicated ip for some website

    example :

    web a : shared ip
    web b : dedicated ip

    can this Script /scripts/build_cpnat working?

    • Attach the floating IP to your droplet. Run the build_cpnat script, and then you should be able to go to modify your cpanel account and assign the droplets IP to site a and the floating IP to site b.

      That should work.
      Using floating IPs as dedicated IPs seems a bit frowned upon here. Especially since you can only ever have the droplets IP and a floating IP assigned to it. You’ll never be able to have 3 IPs for example. If you are using dedicated IP for SSL, you don’t need to. Newer cpanel versions use SNI which is like virtual hosts for ssl. It works great. One IP, multiple sites, different ssl certs.

      Hope it helps, let me know how it goes.

@bogdandynamic - could you please elaborate how you achieved cpanel server duplication / mirror? Was it both ways? I’m trying to do the same. Thanks in advance :-)

Hi @ficklefish . It’s not cpanel server duplication really. I had only one droplet with cpanel installed on it, but had 2 domains (2 separate accounts) on cpanel.
Can you explain your scenario better so I can understand what your problem is ? Maybe I can help you resolve the situation.

Hi @bogdandynamic thanks for your reply.

I am struggling to find a way to stick a load balancer in front of cpanel server. I want to do it for redundancy in case the node fails.

Obviously the issue is with keeping cpanel server properly duplicated across two instances as there is no native support within cpanel for that! I wish I could dump cpanel, the problem is so many customers love it and want it !

Hello @ficklefish. I now understand what your problem is. You need redundancy in accessing cpanel ? Or the websites hosted within the server. If your answer is the latter, you could just use nginx as a proxy in front of apache to “load-balance” the traffic. But if you need a solution in the first scenario, I cannot help you. Personally I maintain a physical server which hosts more than 150 websites and more than 20 virtual machines hosted on G.Cloud. And never have I had problems accessing cpanel if not busting some system global configuration or physically damaging the hardware.
Hope this helps in some manner. Best of luck!

Hi @bogdandynamic thanks for your reply - been a while and I am now looking at GCP - are you still using cpanel on GCP? Is it redundant - i.e. load balanced on there, or you just reply on GCP “stability”? I simply want a way to make cpanel HA ;-)

Hi @ficklefish. Haven’t used cpanel on GCP for a while now. I’ve implemented my own farm of hosting servers on baremetals. Much simpler. :)