Reputation: 1741
Ubuntu 14.04 with lts nginx webserver using gunicorn for flask app.
How do I get my flask app http available as my computer name which is 'argonaut'?
For example, I want the behavior I get when I use the flask webserver in which my app is accessed using
http://argonaut:8080
http://localhost:8080,
http://0.0.0.0:8080, or
http://127.0.0.1
When I go through gunicorn and nginx, it is only available through localhost, 127.0.0.1
I've edited my config files to death, and I've only managed to break the app. nginx config(please be kind, I've read the docs and am very confused)
server {
listen 80;
server_name argonaut;
root /hello;
access_log /logs/access.log;
error_log /logs/error.log;
location / {
proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
if (!-f $request_filename) {
proxy_pass http://0.0.0.0:8000;
break;
}
}
}
I set server to 'argonaut' which is my computer name.
I start gunicorn with unicorn hello:app
.
from flask import Flask
from werkzeug.contrib.fixers import ProxyFix
app = Flask(__name__)
@app.route('/')
def hello():
return "Helloo world!"
app.wsgi_app = ProxyFix(app.wsgi_app)
if __name__ == '__main__':
app.run()
chet@argonaut:~$ cat /etc/hosts
127.0.0.1 localhost
127.0.1.1 argonaut
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
Thanks!
Upvotes: 0
Views: 2505
Reputation: 127180
You add your hostname to the 127.0.0.1 line in your /etc/hosts file. Notice that right now, it's on the 127.0.1.1 line. Ubuntu does this for some reason.
See also: https://serverfault.com/q/363095/179471
Upvotes: 2