###############################nginx.conf 整配置###############################
#user nobody; # user 主模块指令,指令nginx worker 执行用户和用户组(user xxxuser xxxgroup) ,默认由nobody执行
worker_processes 1; # worker_processes 主模块指令,指令nginx执行进程数,每一个进程平均耗10m-12m内存,单核为1,多核为n #error_log logs/error.log; # 全局日志 输出级别debug,info,notice,warn,error,crit ,当中debug输出日志最为具体
#error_log logs/error.log notice; #级别 notice
#error_log logs/error.log info; #级别 info #pid logs/nginx.pid; #pid 指令 指定进程id存储位置 events {
worker_connections 1024; #events 指令 指令nginx 工作模式和连接数上限
} http { #http服务器配置
include mime.types; #包括文件mime.types
default_type application/octet-stream; #默觉得二进制流 #日志格式的设定
#log_format main '$remote_addr - $remote_user [$time_local] "$request" ' #HttpLog模块指令。日志输出格式,main为日志名称。能够在access_log指令引用
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on; #高效文件传输模式,将tcp_nopush和tcp_nodely设置为on
#tcp_nopush on; #keepalive_timeout 0; #客户端连接保持活动的超时时间,超时后关闭连接
keepalive_timeout 65; #gzip on; #开启gzip压缩 实时压缩输出数据流 #server虚拟主机配置1
server {
listen 80; #port
server_name www.luozhonghua1.com; #ip或域名,能够多个www.abc.com,127.0.0.1 #charset koi8-r; #编码格式 access_log logs/luozhonghua1.access.log main; #虚拟主机訪问日志存放路径 location / {
#root html;
index index.html index.htm;
root /web/www/luozhonghua1.com/htdocs;
} #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;
} #server虚拟主机配置2
server {
listen 80; #port
server_name www.luozhonghua2.com; #ip或域名,能够多个www.abc.com,127.0.0.1 #charset koi8-r; #编码格式 access_log logs/luozhonghua2.access.log main; #虚拟主机訪问日志存放路径 location / {
#root html;
index index.html index.htm;
root /web/www/luozhonghua2.com/htdocs;
} #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;
} #server虚拟主机配置3
include /usr/local/nginx/conf/vhosts/www.luozhonghua2.com.conf;
####/usr/local/nginx/conf/vhosts/www.luozhonghua2.com.conf
#server {
# listen 80;
# server_name www.luozhonghua3.com
# access_log logs/luozhonghua3.access.log.main;
# location / {
# index index.html;
# root /web/www/luozhonghua3.com/htdocs;
# }
#}
####/usr/local/nginx/conf/vhosts/www.luozhonghua2.com.conf #nginx反向代理负载均衡配置
upstream myserver{
server 192.168.1.101:80 weight=3 max_fails=3 fail_timeout=20s;
server 192.168.1.102:80 weight=1 max_fails=3 fail_timeout=20s;
server 192.168.1.103:80 weight=4 max_fails=3 fail_timeout=20s;
} server{
listen 80;
server_name www.luozhonghua.com 192.168.1.100;
index index.htm index.html
root /web/root; location / {
proxy_pass http://myserver;
proxy_next_upstream http_500 http_502 http_503 error timeout invalid_header;
include /usr/local/nginx/conf/proxy.conf;
} } ######/usr/local/nginx/conf/proxy.conf文件内容
#proxy_redirect off;
#proxy_set_header Host $host;
#proxy_set_header X-Real-IP $remote_addr;
#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#client_body_buffer_size 128k;
#proxy_connect_timeout 90;
#proxy_send_timeout 90;
#proxy_read_timeout 90;
#proxy_buffer_size 4k;
#proxy_buffers 4 32k;
#proxy_busy_buffers_size 64k;
#proxy_temp_file_write_size 64k;
######proxy.conf文件内容 #防盗链接设置
location ~* \.(jpg|gif|png|swf|flv|wma|wmv|asf|mp3|mmf|zip|rar)${
valid_referers none blocked *.luozhonghua.com luozhonghua.com;
if($invalid_referer)
{
rewrite ^/ http://www.luozhonghua.com/img/error.gif
#return 403;
} location /images{
root /usr/local/nginx/html;
valid_referers none blocked *.luozhonghua.com luozhonghua.com;
if($invalid_referer){
return 403;
}
}
} #日志切割配置
#/bin/bash
savepath_log='/home/nginx/logs' # 切割后日志存放路径
nglogs='/usr/local/nginx/logs' # nginx日志文件存放路径 mkdir -p $savepath_log/$(date+%Y)/$(date+%m)
mv $nglogs/access.log $savepath_log/$(date+%Y)/$(date+%m)/access.$(date+%Y%m%d).log
mv $nglogs/error.log $savepath_log/$(date+%Y)/$(date+%m)/error.$(date+%Y%m%d).log
kill -USR1 'cat /usr/local/nginx/logs/nginx.pid' #通过nginx信号USR1实现日志自己主动切换功能 # proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#} # deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
} # another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias; # location / {
# root html;
# index index.html index.htm;
# }
#} # HTTPS server
#
#server {
# listen 443;
# server_name localhost; # ssl on;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key; # ssl_session_timeout 5m; # ssl_protocols SSLv2 SSLv3 TLSv1;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on; # location / {
# root html;
# index index.html index.htm;
# }
#} }

nginx.conf 完整的集群配置的更多相关文章

  1. Hadoop集群配置(最全面总结 )(转)

    Hadoop集群配置(最全面总结) huangguisu 通常,集群里的一台机器被指定为 NameNode,另一台不同的机器被指定为JobTracker.这些机器是masters.余下的机器即作为Da ...

  2. windows配置nginx实现负载均衡集群

    windows配置nginx实现负载均衡集群2014-08-20 09:44:40   来源:www.abcde.cn   评论:0 点击:617 网上大部分关于nginx负载均衡集群的教程都是lin ...

  3. nginx+tomcat集群配置(4)--rewrite规则和多应用根目录设定思路

    前言: nginx中有一块很重要的概念, 就是rewrite规则. 它会对URL进行修改, 然后进行内部的重定向. rewrite授予了nginx更多的自由, 使得后级服务的接入更加地方便. 本文将简 ...

  4. nginx+tomcat集群配置(1)---根目录设定和多后端分发配置

    前言: 对于javaer而言, nginx+tomcat集群配置, 已然成了web应用部署的主流. 大公司如此, 小公司亦然. 对于个人开发者而言, 资源有限, 往往多个web应用混部于一台服务器(云 ...

  5. Nginx+Tomcat+MemCached 集群配置手册

    系统实施文档 Nginx+Tomcat+MemCached 集群配置手册 目    录 第1章   概述 1.1   目标 互联网的快速发展带来了互联网系统的高负载和高可用性, 这要求我们在设计系统架 ...

  6. windows配置nginx实现负载均衡集群 -请求分流

    windows配置nginx实现负载均衡集群 一.windows上安装nginx 1.下载nginx的windows版本http://nginx.org/en/download.html 2.把压缩文 ...

  7. 使用apache和nginx代理实现tomcat负载均衡及集群配置详解

    实验环境: 1.nginx的代理功能 nginx proxy: eth0: 192.168.8.48 vmnet2 eth1: 192.168.10.10 tomcat server1: vmnet2 ...

  8. Nginx+Tomcat集群配置

    Nginx+Tomcat集群配置 一台虚拟机作为Nginx服务 两太虚拟机配置Tomcat+jdk环境 Nginx测试 启动: cd usr/local/nginx/sbin ./nginx ---& ...

  9. Nginx+Memcached+Tomcat集群配置实践(Sticky Session)

    准备工作 创建一个简单的web应用,名为session.其中有两个页面,分别如下所示: 页面login.jsp <%@ page language="java" conten ...

随机推荐

  1. Oracle使用并行建索引须要注意的问题

    建索引时.我们为了建索引快.会加上并行,加上并行之后.此列索引就会是并行了. 訪问有并行度的索引时,CBO可能可能会考虑并行运行.这可能会引发一些问题,如在server资源紧张的时候用并行会引起更加严 ...

  2. directx11编程中遇到的错误及解决方法

    (2016-05-10)xnamath.h 报错: 在标识符"XMConvertToRadians"的前面 报错如下: >d:\program files\microsoft ...

  3. SSH2.0编程 ssh协议过程实现(转)

    SSh协议: 全称为Secure Shell,即很安全的shell,主要目的是用来取代传统的telnet和r系列命令(rlogin,rsh,rexec等)远程登录和远程执行命令的工具,实现远程登录和远 ...

  4. [渣译文] SignalR 2.0 系列: 支持的平台

    原文:[渣译文] SignalR 2.0 系列: 支持的平台 英文渣水平,大伙凑合着看吧,并不是逐字翻译的…… 这是微软官方SignalR 2.0教程Getting Started with ASP. ...

  5. LR杂记 - loadrunner各项指标结果分析

    Transactions (用户事务分析) 用户事务分析是站在用户角度进行的基础性能分析. 1 . Transation Sunmmary (事务综述) 对事务进行综合分析是性能分析的第一步,通过分析 ...

  6. 阿里2015回顾面试招收学历(获得成功offer)

    1. 引言 继上次"百度2015校园招聘面试题回顾录(成功拿到offer)"文章过后,大家都希望除了题目之外.最好能给出自己当时的回答情况,看看有没有什么回答技巧,这样更有參考价值 ...

  7. 深入研究Java类载入机制

    深入研究Java类载入机制   类载入是Java程序运行的第一步,研究类的载入有助于了解JVM运行过程,并指导开发人员採取更有效的措施配合程序运行. 研究类载入机制的第二个目的是让程序能动态的控制类载 ...

  8. linux学习(一个) 在unbuntu通过添加新的用户

    最近安装了双系统,开始折腾unbuntu该.Linux系统是一个多用户操作系统,非常多的人才完整的操作需要管理员权限,完全管理员权限是非常重要的.人谁是刚开始学习,般用户的权限即可了,相对于刚開始学习 ...

  9. android tips—NumberPicker,DataPicker,TimePicker样式改动

    在使用NumberPicker.DataPicker,TimePicker这几个控件时,非常easy出现例如以下这个界面 可是我们想要的却是以下图示的结果 改动Application.activity ...

  10. iOS coreData

    static int row=0; static const NSString *kStoryboardName = @"LRCoreDataViewController"; st ...