Question

create subdomain on the same droplet for Nginx flask apps

Posted August 10, 2021 110 views
NginxUbuntuDNSFlask

I have followed along the tutorial on creating flask app and deploying it through Nginx

with block file defined as follows, I was wondering how can I create another subdomain that would host another flask app on the same droplet (e.g., test.your_domain).

server {
    listen 80;
    server_name your_domain www.your_domain;

    location / {
        include uwsgi_params;
        uwsgi_pass unix:/home/sammy/myproject/myproject.sock;
    }
}
edited by KFSys

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 @sharaf,

You need to point your subdomain to your Droplet with DigitalOcean first.

Once this is done, create a new Nginx config with the name of your droplet
in your Nginx folder : /etc/nginx/sites-available/. Let’s assume your domain is test.yourdomain. Name the file test.yourdomain.conf.

Now you can follow the same tutorial you’ve posted for your new domain with the only difference, you just need to change the port of your flask app so that your reverse proxy works properly.