【发布时间】:2017-07-30 06:08:13
【问题描述】:
我的设置
带有 lts nginx 网络服务器的 Ubuntu 14.04 使用 gunicorn 用于烧瓶应用程序。
问题
如何让我的烧瓶应用程序 http 可用作我的计算机名称“argonaut”?
例如,我想要使用烧瓶网络服务器时获得的行为,我的应用程序在该服务器中使用
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访问
我的努力
我已经将我的配置文件编辑到死,我只是设法破坏了应用程序。 nginx 配置(请善待,我已阅读文档但很困惑)
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 开始 gunicorn。
烧瓶应用程序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
谢谢!
【问题讨论】:
标签: python nginx flask gunicorn