404尝试通过uWSGI从nginx上运行的Flask应用程序获取索引时

时间:2015-06-01 21:42:03

标签: python nginx flask uwsgi

我正试图在this tutorial之后的Ubuntu Droplet上使用uWSGI在nginx上运行Flask应用程序。

所有中间测试都可以正常工作,直到最后一次测试所有组件一起工作。

这是Flask应用程序所在的位置。

dsaltares@saltares:/home/dsaltares/conjugate/site: tree .
.
├── conjugate.ini
├── conjugate.py
├── conjugate.sock
├── wsgi.py

conjugate.py中的相关部分     bp =蓝图('bp',名称,template_folder ='templates')

application = Flask(__name__)
application.config['APPLICATION_ROOT'] = '/conjugate'
application.register_blueprint(bp, url_prefix='conjugate')

@bp.route('/')
def index():
    return render_template('index.html') 

wsgi.py文件

from conjugate import application

if __name__ == '__main__':
    application.run()

conjugate.ini文件

[uwsgi]
module = wsgi

master = true
processes = 5

socket = conjugate.sock
chmod-socket = 660
vacuum = true

die-on-term = true
uid = dsaltares
gid = www-data

正常运行uwsgi --socket 0.0.0.0:8000 --protocol=http -w wsgi非常合适。我可以从笔记本电脑访问该应用程序。

/etc/init/conjugate.conf文件

description "uWSGI server instance configured to serve conjugate"

start on runlevel [2345]
stop on runlevel [!2345]

setuid dsaltares
setgid www-data

env PATH=/home/dsaltares/conjugate/env/bin
chdir /home/dsaltares/conjugate/site
exec uwsgi --ini conjugate.ini

现在是/etc/nginx/sites-available/default文件

server {
        listen 80;

        fastcgi_buffers 16 16k;
        fastcgi_buffer_size 32k;

        root /usr/share/nginx/html;

        index index.html index.htm index.nginx-debian.html index.php;

        server_name example.com;

        location = / {
            # Redirect to /blog
            return 301 http://example.com/blog;
        }

        location /blog/ {
            try_files $uri $uri/ /blog/index.php?$args;
        }

        location ~ /\.ht {
            deny all;
        }

        location ~ \.php$ {
            ...
        }

        location /conjugate/ {
            include uwsgi_params;
            uwsgi_pass unix:/home/dsaltares/conjugate/site/conjugate.sock;
        }
}

sudo service conjugate restartsudo service nginx restart之后尝试访问http://example.com/conjugate我得到:

404 The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.

sudo tail -f /var/log/nginx/error.log未显示任何错误。

有什么想法吗?非常感谢你

0 个答案:

没有答案