By 332006
I’m running a simple backend using Python (flask) and I have set up an api which returns something on my droplet. I can access it by: http://<droplet-ip>/<app_route>. This works great but for the sake of not just giving out my server’s ip directly to everyone I wanted to add my domain to it. I have set my domain’s DNS records to DigitalOcean a while ago (over a month ago) and now I want to use it.
I created an A record with example.mydomain.com and pointed it to my droplet. How do I make it so example.mydomain.com routes to the previously mentioned http://<droplet-ip>/<app_route>?
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!
Accepted Answer
Hi!
First off, grats on your app, droplet and domain :)
Secondly, after you create the DNS record and point it at your Droplet’s IP, you sometimes have to configure your web server software to handle “virtual hosts”.
Here’s an example with nginx: How To Set Up Nginx Server Blocks (Virtual Hosts) on Ubuntu 16.04
This might be helpful too, if you do not have nginx currently in use (or another web server like apache): How To Serve Flask Applications with Gunicorn and Nginx on Ubuntu 18.04
Hope this helps and good luck! Let us know if you have any more questions.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.