简体   繁体   English

Nginx + bottle + uwsgi服务器在每个请求上返回404

[英]Nginx+bottle+uwsgi Server returning 404 on every request

I have setup an Nginx server with following configuration: 我已经使用以下配置设置了Nginx服务器:

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()

When I send a GET request to the server I get a 404 even though the routes are perfectly set. 当我将GET请求发送到服务器时,即使路由设置正确,我也会收到404。

Here is the uwsgi.log : 这是uwsgi.log

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

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

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- *在[周五6月21日04:47:26]启动uWSGI 1.0.3-debian(64bit)

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-使用以下版本编译:4.6.3 on 2012年7月17日02:26:54

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

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

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

Fri Jun 21 04:47:26 2013 - setgid() to 33 2013年6月21日星期五04:47:26-setgid()至33

Fri Jun 21 04:47:26 2013 - setuid() to 33 2013年6月21日星期五04:47:26-setuid()至33

Fri Jun 21 04:47:26 2013 - your memory page size is 4096 bytes 2013年6月21日星期五04:47:26-您的内存页面大小为4096字节

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套接字0绑定到UNIX地址/ run / uwsgi / app / uwsgi / socket fd 5

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-uwsgi套接字1绑定到UNIX地址/tmp/uwsgi.notesapi.socket fd 6

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-Python版本:2.7.3(默认,2012年8月1日,05:25:23)[GCC 4.6.3]

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

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

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-您的服务器套接字监听待办事项限制为100个连接2013年6月21日星期五04 :47:26-*操作模式:预分叉*

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

Fri Jun 21 04:47:26 2013 - * no app loaded. 2013年6月21日星期五04:47:26- *未加载任何应用程序。 going in full dynamic mode * 进入全动态模式*

Fri Jun 21 04:47:26 2013 - * uWSGI is running in multiple interpreter mode * 2013年6月21日星期五04:47:26- * uWSGI在多种解释器模式下运行*

Fri Jun 21 04:47:26 2013 - spawned uWSGI master process (pid: 25575) 2013年6月21日星期五04:47:26-生成uWSGI主进程(pid:25575)

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

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

/home/ubuntu/notesAPI/src / home / ubuntu / notesAPI / src

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

I am pretty new to uwsgi and nginx. 我对uwsgi和nginx很陌生。 I can't seem to figure out the problem. 我似乎无法找出问题所在。

Are you sure that NGINX and UWSGI are working properly? 您确定NGINX和UWSGI正常工作吗? 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 很多事情可能是错误的,我建议您遵循以下指南: https : //uwsgi.readthedocs.org/en/latest/tutorials/Django_and_nginx.html

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. 这是使用Django设置NGINX和UWSGI的逐步步骤,但我敢肯定您可以将其应用于除Django之外的任何其他Web应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM