我的设置
Ubuntu 14.04与lts nginx webserver使用gunicorn为烧瓶app .
问题
如何将我的烧瓶应用程序http作为我的计算机名称'argonaut'?
例如,我想要当我使用使用 **** 访问我的应用程序的flask webserver时获得的行为
http://argonaut:8080
http://localhost:8080,
http://0.0.0.0:8080, or
http://127.0.0.1
问题
当我通过gunicorn和nginx时,它只能通过localhost,127.0.0.1获得
我的努力
我've edited my config files to death, and I' ve只是设法打破了应用程序 . nginx config (请善待,我已经阅读了文档并且非常困惑)
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;
}
}
}
我将服务器设置为'argonaut',这是我的计算机名称 .
我用 unicorn hello:app
开始枪手 .
flask应用程序hello.py
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()
我的/ etc / hosts文件
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
谢谢!
1 回答
您将主机名添加到/ etc / hosts文件中的127.0.0.1行 . 请注意,现在,它位于127.0.1.1行 . Ubuntu出于某种原因这样做 .
另见:https://serverfault.com/q/363095/179471