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!
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.
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.