###############################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. FastDFS_v5.05+nginx+cache集群安装配置手册

    转载请出自出处:http://www.cnblogs.com/hd3013779515/ 1.FastDFS简单介绍 FastDFS是由淘宝的余庆先生所开发,是一个轻量级.高性能的开源分布式文件系统, ...

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

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

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

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

  4. Nginx+Tomcat集群配置

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

  5. kubeadm安装kubernetes 1.13.1集群完整部署记录

    k8s是什么 Kubernetes简称为k8s,它是 Google 开源的容器集群管理系统.在 Docker 技术的基础上,为容器化的应用提供部署运行.资源调度.服务发现和动态伸缩等一系列完整功能,提 ...

  6. RabbitMQ集群安装配置+HAproxy+Keepalived高可用

    RabbitMQ集群安装配置+HAproxy+Keepalived高可用 转自:https://www.linuxidc.com/Linux/2016-10/136492.htm rabbitmq 集 ...

  7. 虚拟机搭建Zookeeper服务器集群完整笔记

    虚拟机搭建Zookeeper服务器集群完整笔记 本笔记主要记录自己搭建Zookeeper服务器的全过程,默认已经安装部署好Centos7. 一.虚拟机下Centos无法联网解决方案 1.首先调整虚拟机 ...

  8. Centos7+nginx+keepalived集群及双主架构案例

    目录简介 一.简介 二.部署nginx+keepalived 集群 三.部署nginx+keepalived双主架构 四.高可用之调用辅助脚本进行资源监控,并根据监控的结果状态实现动态调整 一.简介 ...

  9. 利用nginx进行集群部署

    现在一般的服务器都是集群的情况了,所以准备搞集群部署下. nginx用的是第三方的openrestynginx.首先安装nginx,我的系统是UBuntu,安装方法也很简单,见官网. 自己采用了默认安 ...

随机推荐

  1. poj 3461 (模式串T在主串S中出现的次数)

    求模式串在主串中出现的次数Sample Input 3BAPCBAPCAZAAZAZAZAVERDIAVERDXIVYERDIANSample Output 130 #include <iost ...

  2. hdu 4549 M斐波拉契 (矩阵快速幂 + 费马小定理)

    Problem DescriptionM斐波那契数列F[n]是一种整数数列,它的定义如下: F[0] = aF[1] = bF[n] = F[n-1] * F[n-2] ( n > 1 ) 现在 ...

  3. C# 关键字const与readonly的区别

    尽管你写了很多年的C#的代码,但是可能当别人问到你const与readonly的区别时候,还是会小小的愣一会吧~ 笔者也是在看欧立奇版的<.Net 程序员面试宝典>的时候,才发现自己长久以 ...

  4. optional

    public class Test { public static void main(String[] args) { People people = new People(); Optional& ...

  5. java.lang.NumberFormatException: multiple points问题

    一般这种问题主要是因为SimpleDateFormat在多线程环境下,是线程不安全的,所以如果你在多线程环境中共享了SimpleDateFormat的实例,比如你在类似日期类中定义了一个全局的Simp ...

  6. URAL - 1078 Segments

    URAL - 1078 题目大意:有n条线段,一个线段a 完全覆盖另一个线段b 当且仅当,a.l < b.l && a.r>b.r.问你 一个线段覆盖一个线段再覆盖一个线段 ...

  7. BZOJ1008 [HNOI2008]越狱 快速幂

    欢迎访问~原文出处——博客园-zhouzhendong 去博客园看该题解 题目传送门 - BZOJ1008 题意概括 监狱有连续编号为1...N的N个房间,每个房间关押一个犯人,有M种宗教,每个犯人可 ...

  8. 【Java】 剑指offer(27) 二叉树的镜像

    本文参考自<剑指offer>一书,代码采用Java语言. 更多:<剑指Offer>Java实现合集   题目 请完成一个函数,输入一个二叉树,该函数输出它的镜像. 思路 画图可 ...

  9. turbo boost - 睿频加速

    turbo boost就是英特尔睿频加速技术 英特尔睿频加速技术是英特尔酷睿 i7/i5 处理器的独有特性,也是英特尔新宣布的一项技术.这项技术可以理解为自动超频.当开启睿频加速之后,CPU会根据当前 ...

  10. ADI SHARC 学习之PLL

    PLL Block Diagram             Power Management Registers (PMCTL, PMCTL1)The following sections descr ...