Setting up a sub-domain to point to a flask application on same droplet (with uwsgi and nginx on Ubuntu 15.10)

I have a domain called which points to a static html page, in /var/www/

I want to host a Flask application on same droplet (different port maybe?), which is accessible using a subdomain

I followed instructions here, and here, but they seem not to be working for me right now.

Here is a how my Zone file looks like currently -

$TTL 1800 IN SOA 1451918078 10800 3600 604800 1800 1800 IN NS 1800 IN NS 1800 IN NS 1800 IN A 111.222.333.44
* 1800 IN CNAME

I have created an in /var/www/ which has

from flask import Flask
application = Flask(__name__)

def hello():
    return 'Hello World!'

if __name__ == "__main__":'')

I have 2 files in /etc/nginx/sites-available

Here is what looks like:

server {
    listen 80;
    server_tokens off;

     location / {
         include uwsgi_params;
         uwsgi_pass unix:/tmp/abc.sock;

     location /static {
         alias /var/www/;

     ## Only requests to our Host are allowed
     if ($host !~ ^(|$ ) {
        return 444;

Here is what /etc/uwsgi/apps-available/ looks like

vhost = true
socket = /tmp/demo.sock
venv = /var/www/
chdir = /var/www/
module = app
callable = application

master = true
processes = 5

chmod-socket = 660
vacuum = true

die-on-term = true works fine, while is not running. I don’t get any error while starting service nginx and uwsgi. I am however beginner in both of them. Please guide me on what I am doing wrong

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.

When finding problems en debugging them its always usefull to use logs to see what is going on. Define your logs and check what nginx tells you once you access the website :

        error_log /var/log/demo.abc_error.log;
        access_log /var/log/demo.abc_access.log combined;