Nginx + bottle + uwsgi服务器在每个请求上返回404 [英] Nginx+bottle+uwsgi Server returning 404 on every request

查看:75
本文介绍了Nginx + bottle + uwsgi服务器在每个请求上返回404的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用以下配置设置了Nginx服务器:

I have setup an Nginx server with following configuration:

server {
        listen 8080;
        server_name localhost;

        location / {
                include uwsgi_params;
                uwsgi_pass unix:/tmp/uwsgi.notesapi.socket;
                uwsgi_param UWSGI_PYHOME /home/ubuntu/notesAPI/env;
                uwsgi_param UWSGI_CHIDIR /home/ubuntu/notesAPI/src;
                uwsgi_param UWSGI_SCRIPT Notes;
        }

}

我已使用以下初始脚本初始化了瓶子应用程序:

I have setup a bottle app with initial following initial script:

import sys from settings.constants import PROJECT_ROOT print PROJECT_ROOT sys.path.insert(0, PROJECT_ROOT)

import bottle from bottle import Bottle, debug from settings import routes

Notes = Bottle() routes.set(Notes)

debug(True)
if __name__ == '__main__':
    Notes.run(host='0.0.0.0', port=8080, reloader=True)
else:
    application = bottle.default_app()

当我向服务器发送GET请求时,即使路由设置正确,我也会收到404.

When I send a GET request to the server I get a 404 even though the routes are perfectly set.

这是 uwsgi.log :

[uWSGI]从/usr/share/uwsgi/conf/default.ini获取INI配置

[uWSGI] getting INI configuration from /usr/share/uwsgi/conf/default.ini

[uWSGI]从/etc/uwsgi/apps-enabled/uwsgi.ini中获取INI配置

[uWSGI] getting INI configuration from /etc/uwsgi/apps-enabled/uwsgi.ini

2013年6月21日星期五04:47:26- *在[2013年6月21日星期五04:47:26]启动uWSGI 1.0.3-debian(64位)*

Fri Jun 21 04:47:26 2013 - * Starting uWSGI 1.0.3-debian (64bit) on [Fri Jun 21 04:47:26 2013] *

2013年6月21日星期五04:47:26-于2012年7月17日02:26:54版本4.6.3编译

Fri Jun 21 04:47:26 2013 - compiled with version: 4.6.3 on 17 July 2012 02:26:54

2013年6月21日星期五04:47:26-当前工作目录:/

Fri Jun 21 04:47:26 2013 - current working directory: /

2013年6月21日星期五04:47:26-将pidfile写入/run/uwsgi/app/uwsgi/pid

Fri Jun 21 04:47:26 2013 - writing pidfile to /run/uwsgi/app/uwsgi/pid

2013年6月21日星期五04:47:26-检测到二进制路径:/usr/bin/uwsgi-core

Fri Jun 21 04:47:26 2013 - detected binary path: /usr/bin/uwsgi-core

2013年6月21日星期五04:47:26-setgid()到33

Fri Jun 21 04:47:26 2013 - setgid() to 33

2013年6月21日星期五04:47:26-setuid()到33

Fri Jun 21 04:47:26 2013 - setuid() to 33

2013年6月21日星期五04:47:26-您的内存页面大小为4096字节

Fri Jun 21 04:47:26 2013 - your memory page size is 4096 bytes

2013年6月21日星期五04:47:26-uwsgi套接字0绑定到UNIX地址/run/uwsgi/app/uwsgi/socket fd 5

Fri Jun 21 04:47:26 2013 - uwsgi socket 0 bound to UNIX address /run/uwsgi/app/uwsgi/socket fd 5

2013年6月21日星期五04:47:26-uwsgi套接字1绑定到UNIX地址/tmp/uwsgi.notesapi.socket fd 6

Fri Jun 21 04:47:26 2013 - uwsgi socket 1 bound to UNIX address /tmp/uwsgi.notesapi.socket fd 6

2013年6月21日星期五04:47:26-Python版本:2.7.3(默认值,2012年8月1日,05:25:23)[GCC 4.6.3]

Fri Jun 21 04:47:26 2013 - Python version: 2.7.3 (default, Aug 1 2012, 05:25:23) [GCC 4.6.3]

2013年6月21日星期五04:47:26-将PythonHome设置为/home/ubuntu/notesAPI/env

Fri Jun 21 04:47:26 2013 - Set PythonHome to /home/ubuntu/notesAPI/env

2013年6月21日星期五04:47:26-Python主解释器初始化为0x1f27e60

Fri Jun 21 04:47:26 2013 - Python main interpreter initialized at 0x1f27e60

2013年6月21日星期五04:47:26-您的服务器套接字监听积压被限制为100个连接2013年6月21日星期五04:47:26- *操作模式:预分叉*

Fri Jun 21 04:47:26 2013 - your server socket listen backlog is limited to 100 connections Fri Jun 21 04:47:26 2013 - * Operational MODE: preforking *

2013年6月21日星期五04:47:26-将/home/ubuntu/notesAPI/src/添加到pythonpath中.

Fri Jun 21 04:47:26 2013 - added /home/ubuntu/notesAPI/src/ to pythonpath.

2013年6月21日星期五04:47:26- *未加载任何应用.进入全动态模式*

Fri Jun 21 04:47:26 2013 - * no app loaded. going in full dynamic mode *

2013年6月21日星期五04:47:26- * uWSGI在多种解释器模式下运行*

Fri Jun 21 04:47:26 2013 - * uWSGI is running in multiple interpreter mode *

2013年6月21日星期五04:47:26-产生了uWSGI主进程(pid:25575)

Fri Jun 21 04:47:26 2013 - spawned uWSGI master process (pid: 25575)

2013年6月21日星期五04:47:26-产生了uWSGI worker 1(pid:25583,cores:1)

Fri Jun 21 04:47:26 2013 - spawned uWSGI worker 1 (pid: 25583, cores: 1)

2013年6月21日星期五04:47:26-产生了uWSGI worker 2(pid:25584,cores:1)

Fri Jun 21 04:47:26 2013 - spawned uWSGI worker 2 (pid: 25584, cores: 1)

/home/ubuntu/notesAPI/src

/home/ubuntu/notesAPI/src

2013年6月21日星期五04:55:28-在解释器0x1f27e60上准备好WSGI应用程序0(mountpoint ='')pid:25583(默认应用程序)[pid:25583 | app:0 | req:1/1] 117.196.135.124(){686个字节中的44个变量} [2013年6月21日星期五,04:55:28] GET/=>在188毫秒中生成723个字节(HTTP/1.1 404),在87个字节中生成2个标头(内核0上的1个开关)

Fri Jun 21 04:55:28 2013 - WSGI application 0 (mountpoint='') ready on interpreter 0x1f27e60 pid: 25583 (default app) [pid: 25583|app: 0|req: 1/1] 117.196.135.124 () {44 vars in 686 bytes} [Fri Jun 21 04:55:28 2013] GET / => generated 723 bytes in 188 msecs (HTTP/1.1 404) 2 headers in 87 bytes (1 switches on core 0)

我对uwsgi和nginx相当陌生.我似乎无法找出问题所在.

I am pretty new to uwsgi and nginx. I can't seem to figure out the problem.

推荐答案

您确定NGINX和UWSGI正常工作吗?很多事情可能是错误的,我建议您遵循此指南: https://uwsgi.readthedocs.org/en/latest/tutorials/Django_and_nginx.html

Are you sure that NGINX and UWSGI are working properly? Lot's of things could be wrong, I recommend you to follow this guide: https://uwsgi.readthedocs.org/en/latest/tutorials/Django_and_nginx.html

这是使用Django设置NGINX和UWSGI的分步操作,但是我敢肯定您可以将其应用于除Django之外的任何其他Web应用程序.

It's a step by step to setup NGINX and UWSGI with Django but I'm pretty sure you can apply it to any other web app than Django.

这篇关于Nginx + bottle + uwsgi服务器在每个请求上返回404的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆