#user nobody;
worker_processes 1;


#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;


#pid logs/nginx.pid;


events {
#定义单个进程的最大连接数(实际最大连接数要除以2)
worker_connections 1024;
}


http {
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;


#gzip on;


upstream cluster.com { #服务器集群名字
server 127.0.0.1:9902 weight=2;
server 127.0.0.1:9901 weight=2;
}


upstream cluster2.com { #服务器集群名字
server 127.0.0.1:9904 weight=1;
server 127.0.0.1:9903 weight=2;
}
server {
listen 9001;
server_name stu.cluster.com;


#charset koi8-r;


#access_log logs/host.access.log main;


location / {
proxy_pass http://cluster.com;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_redirect default;
}


}
server {
listen 9001;
server_name univ.cluster.com;


#charset koi8-r;


#access_log logs/host.access.log main;


location / {
proxy_pass http://cluster2.com;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_redirect default;
}


}


# 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 ssl;
# server_name localhost;


# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;


# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;


# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;


# location / {
# root html;
# index index.html index.htm;
# }
#}


}

 

Nginx配置 简单写了个的更多相关文章

  1. Nginx配置简单负载均衡

    前提:因为本次需要两个软件在本机不同端口提供http服务,于是我准备一个tomcat在8080端口,另一个nodejs程序在3000端口,前者自不用提,后者可以到https://www.cnblogs ...

  2. nginx 配置简单网站项目(linux下)

    1.新建html2与html3两个网站项目测试,而html是本身就有,记得到/etc/hosts 添加dns记录 2.修改nginx.conf文件 3.测试访问 中间用到一些nginx的命令,就不截图 ...

  3. nginx 配置简单的静态页面

    nginx 文件服务配置,MIME和 default_type https://blog.csdn.net/qq_26711103/article/details/81116900 nginx 静态页 ...

  4. Nginx配置简单基于域名的虚拟主机

    首先修改hosts文件,让浏览器在看到a.com或是www.a.com的网址时知道上哪里去找: # Copyright (c) 1993-2009 Microsoft Corp. # # This i ...

  5. nginx 配置简单 301 重定向

    server { listen ; server_name your.first.domain; rewrite ^(.*) http://your.second.domain:8000$1 perm ...

  6. nginx 配置简单反向代理

    假设端口号是 3000 server { listen ; server_name your.domain; location / { proxy_pass http://127.0.0.1:3000 ...

  7. Docker+nginx+tomcat7配置简单的负载均衡

    本文为原创,原始地址为:http://www.cnblogs.com/fengzheng/p/4995513.html 本文介绍在Docker上配置简单的负载均衡,宿主机为Ubuntu 14.04.2 ...

  8. Linux yum的配置 , python环境管理, nginx搭建简单学习

    Linux yum的配置 , python环境管理, nginx搭建简单学习 一丶配置yum的数据仓库 ### yum 工具, 方便,自行解决软件之间的依赖关系. # 配置yum源仓库 (可以使用,清 ...

  9. linux搭建一个配置简单的nginx反向代理服务器 2个tomcat

    1.我们只要实现访问nginx服务器能跳转到不同的服务器即可,我本地测试是这样的, 在nginx服务器里面搭建了2个tomcat,2个tomcat端口分别是8080和8081,当我输入我nginx服务 ...

随机推荐

  1. BroadcastReceiver用法

    动态注册广播接收器 1.创建一个Receiver继承BroadcastReceiver,并重写onReceiver() 2.在Activity的OnCreate()中添加广播接收器想要接收的actio ...

  2. jmeter 打不开 提示“Not able to find Java executable or version”的解决办法

    Not able to find Java executable or version. Please check your Java installation . errorlevel=2Not a ...

  3. spring bean id重复覆盖的问题解决

    问题: 当我们的web应用做成一个大项目之后,里面有很多的bean配置,如果两个bean的配置id是一样的而且实现类也是一样的,例如有下面两份xml的配置文档: beancontext1.xml &l ...

  4. python开发面向对象进阶:反射&内置函数

    isinstance和issubclass isinstance(obj,cls)检查是否obj是否是类 cls 的对象或者子类的对象 class Foo(object): pass class ba ...

  5. C++获取Lua全局变量和执行Lua多参数多返回值函数

    C++代码: // LuaAndC.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <iostream> #i ...

  6. jQuery笔记——基础知识

    jQuery是一个JavaScript库,它通过封装原生的JavaScript函数得到一整套定义好的方法.在jQuery程序中,不管是页面元素的选择.内置的功能函数,都是美元符号“$”来起 始的.而这 ...

  7. Py修行路 python基础 (十六)面向对象编程的 继承 多态与多态性 封装

    一.继承顺序: 多继承情况下,有两种方式:深度优先和广度优先 1.py3/py2 新式类的继承:在查找属性时遵循:广度优先 继承顺序是多条分支,按照从左往右的顺序,进行一步一步查找,一个分支走完会走另 ...

  8. haproxy启动时提示失败

    haproxy启动时提示失败:[ALERT] 164/110030 (11606) : Starting proxy linuxyw.com: cannot bind socket 这个问题,其实就是 ...

  9. Python中常见的异常处理

    异常和错误 part1:程序中难免出现错误,而错误分成两种 1. 语法错误(这种错误,根本过不了Python解释器的语法检测,必须在程序执行前就改正) # 语法错误示范一 if # 语法错误示范二 d ...

  10. 微信公众号php从0开发,包括功能(自定义菜单,分享)

    之前写的一篇微信公众号文章. 工作需要,进行此次调研,并记录开发过程. 开发目的,页面授权,页面获取用户头像,用户昵称 微信id, 分享页面. 微信订阅号 无法获取用户个人信息 写在记录前,公众号也是 ...