Question

How can I bind a process to a floating IP?

How can I bind a process(i.e. Web server) to a floating IP address? I want to configure NGINX to listen only on the floating IP. However, Ubuntu doesn’t detect the floating IP at all, and NGINX gives an error whenever I try:

nginx: [emerg] bind() to floating_ip:443 failed (99: Cannot assign requested address)

The config I’m using is:

    server{
        listen floating_ip:443 ssl;
        ssl_certificate /var/www/.acme.sh/domain_name.com/fullchain.cer;
        ssl_certificate_key /var/www/.acme.sh/domain_name.com/domain_name.com.key;
        location /{
            proxy_set_header Host $host;
            proxy_set_header X-Forwarded-For   $proxy_add_x_forwarded_for;
            #proxy_set_header scheme $scheme;
            proxy_set_header X_FORWARDED_PROTO $scheme;
            proxy_pass http://127.0.0.1:80;
        }
    }
Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

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.

Accepted Answer

Thanks to X40C for finding this:

The answer already exists here.

TL;DR

Run the following from your droplet to find the IP to bind to:

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

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.