Question

Make Apache listen on Floating IP only

Posted May 16, 2021 215 views
ApacheNetworking

Our Digital Ocean Droplet has a regular IP address, and we also have a Floating IP address assigned.

I’d like Apache to only listen on the Floating IP address. So any requests that come to Apache via the Droplet’s regular IP address would go unanswered.

I have tried changing

Listen 80
Listen 443

to


Listen FLOATING_IP:80
Listen FLOATING_IP:443

However, Apache fails to start and the following error is in the log:


(99)Cannot assign requested address: make_sock: could not bind to address FLOATING_IP

I’m wondering if Floating IP addresses are re-written to the main Droplet IP address prior to the traffic reaching the Droplet?

Is it possible to achieve what I would like?

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
1 answer

Hi there @DigitalCarrot,

In order to achieve this, what you could do is use the Anchor IP address instead.

You can find the Anchor IP by running this curl command from the server itself:

curl -s http://169.254.169.254/metadata/v1/interfaces/public/0/anchor_ipv4/address

For more information on Anchor IPs, you could take a look at the documentation here:

https://docs.digitalocean.com/products/networking/floating-ips/how-to/find-anchor-ips/

Hope that this helps!
Regards,
Bobby

  • Hi Bobby,

    Thanks for your reply. I had come to the conclusion that the droplet doesn’t actually know anything about the floating IP address, so what I wanted to do wasn’t possible.

    I hadn’t heard about Anchor IP addresses, but that sounds like what we need. I’ll try it later and report back!

    Thanks,

    Gareth

    • Hi there,

      No problem at all! I believe that it should fit your needs, I’ve just tested it with a fresh new Ubuntu Droplet with Apache and it worked as expected. Let me know if you have any questions.

      Regards,
      Bobby