tengine配置实战
2014-05-24 00:00
411 查看
摘要: tengine配置实战
如下配置不够完善,慢慢优化中,请不要在生产上使用
2,安装依赖
3,编译安装
4,开机自启动
#输入如下内容
给该文件授权
然后再测试下试试
主要有什么功能
反向代理的主要作用为:
加密和SSL加速
负载均衡
缓存静态内容
压缩
减速上传
安全
外网发布
未完待续......
维基百科反向代理
如下配置不够完善,慢慢优化中,请不要在生产上使用
环境
CentOS 6.5,Digitalocean Cloud(邀请)下载安装
1,点击这里进入下载页面2,安装依赖
yum -y install pcre-devel yum -y install make gcc gcc-c++ ncurses-devel make zlib zlib-devel yum -y install openssl openssl--devel #devel的安装不上 #到这里下载http://mirror.centos.org/centos/6.5/updates/x86_64/Packages/ wget http://mirror.centos.org/centos/6.5/updates/x86_64/Packages/openssl-devel-1.0.1e-16.el6_5.7.x86_64.rpm #rpm -ivh openssl-devel-1.0.1e-16.el6_5.7.x86_64.rpm #安装时缺少krb5-devel,需要安装krb5 yum -y install krb5-devel #然后在执行rpm命令就可以安装上了 rpm -ivh openssl-devel-1.0.1e-16.el6_5.7.x86_64.rpm
3,编译安装
./configure --prefix=/opt/nginx make sudo make install
4,开机自启动
vi /etc/init.d/nginx
#输入如下内容
#!/bin/bash # nginx Startup script for the Nginx HTTP Server # it is v.0.0.2 version. # chkconfig: - 85 15 # description: Nginx is a high-performance web and proxy server. # It has a lot of features, but it's not for everyone. # processname: nginx # pidfile: /opt/nginx/logs/nginx.pid # config: /opt/nginx/conf/nginx.conf nginxd=/opt/nginx/sbin/nginx nginx_config=/opt/nginx/conf/nginx.conf nginx_pid=/opt/nginx/logs/nginx.pid RETVAL=0 prog="nginx" # Source function library. . /etc/rc.d/init.d/functions # Source networking configuration. . /etc/sysconfig/network # Check that networking is up. [ ${NETWORKING} = "no" ] && exit 0 [ -x $nginxd ] || exit 0 # Start nginx daemons functions. start() { if [ -e $nginx_pid ];then echo "nginx already running...." exit 1 fi echo -n $"Starting $prog: " daemon $nginxd -c ${nginx_config} RETVAL=$? echo [ $RETVAL = 0 ] && touch /var/lock/subsys/nginx return $RETVAL } # Stop nginx daemons functions. stop() { echo -n $"Stopping $prog: " killproc $nginxd RETVAL=$? echo [ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx $nginx_pid } # reload nginx service functions. reload() { echo -n $"Reloading $prog: " #kill -HUP `cat ${nginx_pid}` killproc $nginxd -HUP RETVAL=$? echo } # See how we were called. case "$1" in start) start ;; stop) stop ;; reload) reload ;; restart) stop start ;; status) status $prog RETVAL=$? ;; *) echo $"Usage: $prog {start|stop|restart|reload|status|help}" exit 1 esac exit $RETVAL
给该文件授权
chmod a+x /etc/init.d/nginx
然后再测试下试试
配置实战
nginx.conf
user nobody; worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; error_log logs/error.log error; pid logs/nginx.pid; worker_rlimit_nofile 65535; events { worker_connections 1024; } # load modules compiled as Dynamic Shared Object (DSO) # #dso { # load ngx_http_fastcgi_module.so; # load ngx_http_rewrite_module.so; #} http { limit_req_zone $binary_remote_addr zone=ipLimit:10m rate=5r/s; limit_conn_zone $binary_remote_addr zone=addrLimit:10m; include 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 logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; include gzip.conf; server { listen 80; server_name localhost; #charset koi8-r; access_log logs/host.access.log main; location ~ .*\.(gif|png|css|js|icon)$ { proxy_set_header Host $http_host; proxy_set_header X-Real_IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location ~* .*\.(jpeg|jpg|JPG)$ { proxy_set_header Host $http_host; proxy_set_header X-Real_IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # image_filter resize 480 -; # image_filter_jpeg_quality 50; # image_filter_sharpen 10; # image_filter_buffer 4M; } location / { limit_req zone=ipLimitburst=5; root html; index index.html index.htm; } error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } }
gzip.conf
gzip on; gzip_min_length 1k; gzip_comp_level 3; gzip_buffers 16 64k; gzip_types text/plain application/x-javascript text/css text/javascript; gzip_http_version 1.1; gzip_proxied any; gzip_vary on; gzip_disable "MSIE [1-6].";
实战详解
什么是反向代理
在计算机网络中,反向代理是代理服务器的一种。它根据客户端的请求,从后端的服务器上获取资源,然后再将这些资源返回给客户端。[1]与前向代理不同,前向代理作为一个媒介将互联网上获取的资源返回给相关联的客户端,而反向代理是在服务器端作为代理使用,而不是客户端。主要有什么功能
反向代理的主要作用为:加密和SSL加速
负载均衡
缓存静态内容
压缩
减速上传
安全
外网发布
未完待续......
参考
tengine官方文档维基百科反向代理
相关文章推荐
- 实战1.1下Web.Config配置标记configSections
- 实战dailybuild-cc.net的配置
- Cisco实战配置三层交换的综合案例 .doc
- hibernate3.0+ejb3 annotaion配置实战+spring1.21 annotation事务控制
- dom4j实战(一)——使用dom4j从XML中读取数据源配置
- JBOSS相关配置实战总结
- Solaris 10服务器网络接口配置实战
- 转载:JBOSS相关配置实战总结
- SharePoint WebPart开发实战(一):定制属性及配置界面
- rg-wall100(星网锐捷)防火墙配置实战
- 五一献礼(一)实战分析web.confing中灵活的类配置
- [伊达原创]ubuntu环境下实战河南网通ADSL上网全配置
- FreeBsd6.1 apache虚拟主机配置实战
- 交换机ACL配置实战
- Windows Server 2003 安全配置实战演习
- Windows Server 2003 安全配置实战 copy
- IIS配置wap服务器,让ASP生成wml实战教程
- 实战1.1下Web.Config配置标记configSections
- 实战推荐:某大型思科网络的配置实例
- Solaris网络环境部署HIDS配置实战