nginx + uwsgi+web.py
2012-02-21 21:01
501 查看
Nginx是俄罗斯人Igor Sysoev 编写的一款高性能的HTTP和反向代理服务器。其采用epoll 的机制,官方宣传可支持50000个并发。
下面介绍nginx 作为反向代理负载均衡服务器和HTTP服务器的配置用法。
下图为nginx 作为反向代理均衡服务器,和HTTP 代理服务器的简单配置用法。
upstream frontends 中列出所有服务器地址,nginx 自动均衡分发请求到各个服务器。
http {
# Enumerate all the Tornado servers here
upstream frontends {
ip_hash;
server 192.168.0.1:8888;
server 192.168.0.2:8889;
}
server {
listen 80;
server_name localhost;
location / {
proxy_pass_header Server;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_pass http://frontends; }
}
server {
listen 8000;
server_name Cache;
error_log logs/test.log;
location / {
uwsgi_pass 127.0.0.1:9001;
include uwsgi_params;
}
}
}
第二个server 作为http 服务器,服务于uwsgi + web.py
web.py 简单demo,文件名test.py.
import web
import time
import socket
urls = (
'/', 'index'
)
class index:
def GET(self):
strtime1 =str(time.time())
strtime2 =str(time.time())
return strtime1+"Hello, world!"+strtime2
app = web.application(urls, globals())
application = app.wsgifunc()用uwsgi -s 127.0.0.1:9001 -w test
在启动nginx ,访问l27.0.0.1:8000就看到效果了。
值得一说的是在启动uwsgi时,大家可能会遇到这样的问题
unable to load app 0 (mountpoint='') (callable not found or import error)
这是因为大家被这句话写错了application=app.wsgifunc(),uwsgi 找不到入口地址application = app.wsgifunc()
下面介绍nginx 作为反向代理负载均衡服务器和HTTP服务器的配置用法。
下图为nginx 作为反向代理均衡服务器,和HTTP 代理服务器的简单配置用法。
upstream frontends 中列出所有服务器地址,nginx 自动均衡分发请求到各个服务器。
http {
# Enumerate all the Tornado servers here
upstream frontends {
ip_hash;
server 192.168.0.1:8888;
server 192.168.0.2:8889;
}
server {
listen 80;
server_name localhost;
location / {
proxy_pass_header Server;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_pass http://frontends; }
}
server {
listen 8000;
server_name Cache;
error_log logs/test.log;
location / {
uwsgi_pass 127.0.0.1:9001;
include uwsgi_params;
}
}
}
第二个server 作为http 服务器,服务于uwsgi + web.py
web.py 简单demo,文件名test.py.
import web
import time
import socket
urls = (
'/', 'index'
)
class index:
def GET(self):
strtime1 =str(time.time())
strtime2 =str(time.time())
return strtime1+"Hello, world!"+strtime2
app = web.application(urls, globals())
application = app.wsgifunc()用uwsgi -s 127.0.0.1:9001 -w test
在启动nginx ,访问l27.0.0.1:8000就看到效果了。
值得一说的是在启动uwsgi时,大家可能会遇到这样的问题
unable to load app 0 (mountpoint='') (callable not found or import error)
这是因为大家被这句话写错了application=app.wsgifunc(),uwsgi 找不到入口地址application = app.wsgifunc()
application = app.wsgifunc()
相关文章推荐
- mac下安装nginx+uwsgi+webpy出错解决
- Nginx + uWSGI + web.py 搭建示例
- Cenots下nginx+uwsgi+web.py环境部署总结
- nginx+uwsgi+web.py的部署
- (转)Nginx + uwsgi + web.py + MySQLdb
- uwsgi+web.py+nginx on Ubuntu14.04 LTS
- uwsgi+nginx+web.py备忘
- 部署ubuntu + Nginx + uWSGI + web.py
- linux下搭建nginx+uwsgi+web.py的python web服务器
- nginx连接uwsgi使用web.py框架构造pythonweb项目
- centos7简单搭建nginx+uwsgi+web.py的Python web环境(记录)
- Nginx + uWSGI + web.py 搭建示例
- web.py运行于nginx的uwsgi上
- nginx+uwsgi部署python web(web.py)
- webpy+nginx+uwsgi安装配置
- Nginx+uwsgi+web.py
- ubuntn 配置webpy nginx
- nginx和fastcgi部署web.py问题总结
- uWSGI教程-----使用uWSGI和nginx配置你的web服务器