已经有好几天这个问题了,希望有人会对此有所了解。
基本上我已经使用AWS EC2与uWSGI和NGinx建立了金字塔应用程序。
我对telnet没有任何问题,如下所示:
$ telnet 127.0.0.1 3003
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
Connection closed by foreign host.
接下来当我尝试卷曲时,它显示了以下结果:
$ curl 127.0.0.1:3003
curl: (52) Empty reply from server
我的production.ini文件:
###
# wsgi server configuration
###
[server:main]
use = egg:uwsgi#main
host = 127.0.0.1
port = 3003
###
# logging configuration
# http://docs.pylonsproject.org/projects/pyramid/en/1.6-branch/narr/logging.html
###
[loggers]
keys = root, fruler
[handlers]
keys = console
[formatters]
keys = generic
[logger_root]
level = WARN
handlers = console
[logger_fruler]
level = WARN
handlers =
qualname = fruler
[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = NOTSET
formatter = generic
[formatter_generic]
format = %(asctime)s %(levelname)-5.5s [%(name)s:%(lineno)s][%(threadName)s] %(message)s
[uwsgi]
socket = 127.0.0.1:3003
virtualenv = /home/ec2-user/env
die-on-term = 1
master = 1
daemonize = /home/ec2-user/env/FRuler/uwsgi.log
pidfile = /home/ec2-user/env/FRuler/pid_5000.pid
processes = 4
harakiri = 30
harakiri-verbose = true
limit-post = 5242880
post-buffering = 8192
我的/etc/nginx/nginx.conf文件:
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
#include /etc/nginx/conf.d/*.conf;
server {
#listen <aws.ip.address>:80;
listen 80;
server_name ec2-<aws.ip.address>.ap-southeast-1.compute.amazonaws.com;
#index index.html index.htm index.py;
access_log /var/log/nginx/<domain>.com.log;
error_log /var/log/nginx/<domain>.com.error;
root /home/ec2-user/;
charset utf-8;
location / {
uwsgi_pass 127.0.0.1:3003;
#proxy_pass http://127.0.0.1:3003;
include uwsgi_params;
}
location /static {
root /home/ec2-user/env/FRuler/fruler/;
}
}
}
运行以下命令后:
$ sudo ./bin/uwsgi --ini-paste-logged FRuler/production.ini
[uWSGI] getting INI configuration from FRuler/production.ini
uwsgi的日志文件如下:
*** Starting uWSGI 2.0.12 (64bit) on [Sun May 8 21:58:22 2016] ***
compiled with version: 4.8.5 20150623 (Red Hat 4.8.5-4) on 05 May 2016 01:48:35
os: Linux-3.10.0-327.el7.x86_64 #1 SMP Thu Oct 29 17:29:29 EDT 2015
nodename: ip-172-31-29-104.ap-southeast-1.compute.internal
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 1
current working directory: /home/ec2-user/env
writing pidfile to /home/ec2-user/env/FRuler/pid_5000.pid
detected binary path: /home/ec2-user/env/bin/uwsgi
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
your processes number limit is 3824
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to TCP address 127.0.0.1:3003 fd 3
Python version: 3.4.1 (default, May 5 2016, 01:34:21) [GCC 4.8.5 20150623 (Red Hat 4.8.5-4)]
Set PythonHome to /home/ec2-user/env
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0xf78820
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 404800 bytes (395 KB) for 4 cores
*** Operational MODE: preforking ***
Loading paste environment: config:/home/ec2-user/env/FRuler/production.ini
WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0xf78820 pid: 15848 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 15848)
spawned uWSGI worker 1 (pid: 15852, cores: 1)
spawned uWSGI worker 2 (pid: 15853, cores: 1)
spawned uWSGI worker 3 (pid: 15854, cores: 1)
spawned uWSGI worker 4 (pid: 15855, cores: 1)
我在浏览器中输入了我的AWS网址,显示502网关错误。
我错误地编辑了配置文件中的任何内容吗?