问题
如何在我的ubuntu14.04 lts操作系统(nginx gunicorn)上托管一个flask应用程序,其他用户(windows机器)可以使用我的计算机名访问它?我已接入windows网络,计算机名为“argonaut”。你知道吗
目前
我可以访问该应用程序,但其他计算机没有。但是,如果我使用flask development web服务器从windows计算机运行应用程序,则其他计算机可以访问该应用程序。有什么区别?你知道吗
同样,如果
我在ubuntu上托管
我有访问权限,但其他人在使用时没有
http://argonaut:8000
如果我在windows计算机上运行主机
网络中的每个人都可以使用(所需的访问权限,但我不希望使用windows)
http://argonaut:8000
我不知道从哪里开始调查。你知道吗
我的烧瓶运行.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')
我设置host='0.0.0.0',希望每个人都能访问它。你知道吗
当我跑的时候
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配置
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;
}
}
}
谢谢
目前没有回答
相关问题 更多 >
编程相关推荐