0

question
How do I host a flask app on my ubuntu 14.04 lts os (nginx-gunicorn) that other users (windows machines) can get to it using my computer name? I'm plugged into the windows network and the computer name is 'argonaut'.

Currently
i have access to the app, but other computers do not. However, if I run the app from a windows computer using the flask development web-server, other computers have access to the app. What is the difference?

again, if
i host on ubuntu
I have access but others do not when using

http://argonaut:8000 

if i host on a windows machine
Everyone in the network can access the site using (desired access-but i don't want use windows)

http://argonaut:8000 

I'm not sure where to start investigating.

My Flask run.py

from flask import Flask
from werkzeug.contrib.fixers import ProxyFix
app = Flask(__name__)

@app.route('/')
def hello():
    return "Hellooxx world!"

app.wsgi_app = ProxyFix(app.wsgi_app)

if __name__ == '__main__':
    app.run(host='0.0.0.0')

i set host='0.0.0.0' hoping that it would be accessible to everyone.

when i run

    chet@argonaut:~$ netstat -tupln | grep ':8000'
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp        0      0 127.0.0.1:8000          0.0.0.0:*               LISTEN      3216/python  

nginx config

worker_processes 1;

events {

    worker_connections 1024;

}

http {

    sendfile on;

    gzip              on;
    gzip_http_version 1.0;
    gzip_proxied      any;
    gzip_min_length   500;
    gzip_disable      "MSIE [1-6]\.";
    gzip_types        text/plain text/xml text/css
                      text/comma-separated-values
                      text/javascript
                      application/x-javascript
                      application/atom+xml;

    # Configuration containing list of application servers
    upstream app_servers {

        server 0.0.0.0:8080;
        # server 127.0.0.1:8081;
        # ..
        # .

    }

    # Configuration for Nginx
    server {

        # Running port
        listen 80;

        # Settings to serve static files 
        location ^~ /static/  {

            # Example:
            # root /full/path/to/application/static/file/dir;
            root /app/static/;

        }

        # Serve a static file (ex. favico)
        # outside /static directory
        location = /favico.ico  {

            root /app/favico.ico;

        }

        # Proxy connections to the application servers
        # app_servers
        location / {

            proxy_pass         http://app_servers;
            proxy_redirect     off;
            proxy_set_header   Host $host;
            proxy_set_header   X-Real-IP $remote_addr;
            proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header   X-Forwarded-Host $server_name;

        }
    }
}

Thank you

Chet Meinzer
  • 1,691
  • 2
  • 21
  • 35
  • Possible duplicate: http://stackoverflow.com/questions/7023052/flask-configure-dev-server-to-be-visible-across-the-network – user3378649 Oct 21 '14 at 22:22
  • I wish it was a duplicate. I posted my code to show that i already tried that. But could it be nginx or gunicorn config? – Chet Meinzer Oct 21 '14 at 22:39
  • Are you sure that you HTTP server is listening to the needed address (Try to check using this command: netstat -tupln | grep ':8000') – user3378649 Oct 21 '14 at 22:44
  • I'm not sure i understand the output (added to question). what does listen 3216 mean? – Chet Meinzer Oct 21 '14 at 22:51
  • I assume you're able to access it through its ip though, correct? You can't get it to use the name? – nil Oct 22 '14 at 01:09
  • Also it looks like nginx is listening on 80 and 8080 which is standard web - so if you visited http://host on the default, shouldn't nginx then do the lifting and pass it to the 8000 you have listed. Or. Maybe I'm lost and should turn around here. – nil Oct 22 '14 at 01:13
  • So, when you were visiting port 8000, I think you were bypassing nginx altogether and hitting the app server that is running on port 8000, which nginx needs to be configured to do, which it isn't. – nil Oct 22 '14 at 01:26
  • It doesn't work when i go to the ip. – Chet Meinzer Oct 22 '14 at 04:17

0 Answers0