Nginx作为反向代理支持5000并发---奇点时代

user  nobody;

worker_processes 12;

error_log     logs/error.log;  ###/var/log/nginx/error.log;

pid           logs/nginx.pid;  ###/var/run/nginx.pid;

worker_rlimit_nofile  65535;

events {

use  epoll;

worker_connections    65535;

}

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; ### /var/log/nginx/access.log

client_max_body_size 8m;

client_header_buffer_size 32k;

large_client_header_buffers 4 64k;

sendfile on;

tcp_nopush on;

tcp_nodelay on;

keepalive_timeout 120;

gzip on;

gzip_min_length 1k;

gzip_buffers 4 16k;

gzip_http_version 1.1;

gzip_comp_level 2;

gzip_types text/plain application/x-javascript text/css application/xml;

gzip_vary on;

upstream localhost13914280{
     
      server 192.168.0.139:18080 weight=3 max_fails=2 fail_timeout=3s;
      server 192.168.0.139:28080 weight=3 max_fails=2 fail_timeout=3s;
      server 192.168.0.139:38080 weight=3 max_fails=2 fail_timeout=3s;
      server 192.168.0.139:48080 weight=3 max_fails=2 fail_timeout=3s;
      server 192.168.0.139:58080 weight=3 max_fails=2 fail_timeout=3s;
      server 192.168.0.142:18080 weight=3 max_fails=2 fail_timeout=3s;
      server 192.168.0.142:28080 weight=3 max_fails=2 fail_timeout=3s;
      server 192.168.0.142:38080 weight=3 max_fails=2 fail_timeout=3s;
      server 192.168.0.142:48080 weight=3 max_fails=2 fail_timeout=3s;
      server 192.168.0.142:58080 weight=3 max_fails=2 fail_timeout=3s;
    }

#####First  virtual server

server {

listen              80;

server_name         192.168.0.137;

access_log          logs/var/log/nginx/access.137.log;##/var/log/nginx/

location  /  {

proxy_pass  http://localhost13914280;

proxy_next_upstream http_500  http_502 http_503 error timeout invalid_header;

include  /usr/local/nginx/conf/conf.d/*.conf;

}

}

###########################################################################################

在137和138上建立conf.d目录。这样的做的目的是简化nginx配置文件。

mkdir /usr/local/nginx/conf/conf.d/  &&  cd /usr/local/nginx/conf/conf.d

vi proxy.conf

proxy_redirect off;

proxy_set_header  Host $host;

proxy_set_header  X-Real-IP  $remote_addr;

proxy_set_header  X-Forward-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;

###########################################################################################

error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
          }

}

###Second virtual server

upstream localhost13480{
     
      server 192.168.0.134:18080 weight=3 max_fails=2 fail_timeout=3s;
      server 192.168.0.134:28080 weight=3 max_fails=2 fail_timeout=3s;
      server 192.168.0.134:38080 weight=3 max_fails=2 fail_timeout=3s;
      server 192.168.0.134:48080 weight=3 max_fails=2 fail_timeout=3s;
      server 192.168.0.134:58080 weight=3 max_fails=2 fail_timeout=3s;
    }

server  {

listen 80;

server_name api.geekoin.com;

access_log    logs/api.geekoin.com.log;

location / {

proxy_pass http://localhost13480;

proxy_next_upstream http_500  http_502 http_503 error timeout invalid_header;

include  /usr/local/nginx/conf/conf.d/*.conf;

}

error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
          }

}

upstream localhttps139142443{
     
      server 192.168.0.139:18443 weight=3 max_fails=2 fail_timeout=3s;
      server 192.168.0.139:28443 weight=3 max_fails=2 fail_timeout=3s;
      server 192.168.0.139:38443 weight=3 max_fails=2 fail_timeout=3s;
      server 192.168.0.139:48443 weight=3 max_fails=2 fail_timeout=3s;
      server 192.168.0.139:58443 weight=3 max_fails=2 fail_timeout=3s;
      server 192.168.0.142:18443 weight=3 max_fails=2 fail_timeout=3s;
      server 192.168.0.142:28443 weight=3 max_fails=2 fail_timeout=3s;
      server 192.168.0.142:38443 weight=3 max_fails=2 fail_timeout=3s;
      server 192.168.0.142:48443 weight=3 max_fails=2 fail_timeout=3s;
      server 192.168.0.142:58443 weight=3 max_fails=2 fail_timeout=3s;

}

server {
        listen       443;
        server_name  localhost;
        ssl on;
        ssl_certificate       server.crt;
        ssl_certificate_key   server.key;

location / {

proxy_pass https://localhttps139142443;

proxy_next_upstream http_500  http_502 http_503 error timeout invalid_header;

include  /usr/local/nginx/conf/conf.d/*.conf;

}

}

upstream localhttps134443{
     
      server 192.168.0.134:18443 weight=3 max_fails=2 fail_timeout=3s;
      server 192.168.0.134:28443 weight=3 max_fails=2 fail_timeout=3s;
      server 192.168.0.134:38443 weight=3 max_fails=2 fail_timeout=3s;
      server 192.168.0.134:48443 weight=3 max_fails=2 fail_timeout=3s;
      server 192.168.0.134:58443 weight=3 max_fails=2 fail_timeout=3s;
    }

server {

listen  443;

server_name api.geekoin.com;

access_log    logs/api.geekoin.com.log;

location / {

proxy_pass http://localhttps134443;

proxy_next_upstream http_500  http_502 http_503 error timeout invalid_header;

include  /usr/local/nginx/conf/conf.d/*.conf;

}

error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
          }

}

}

时间: 2024-08-01 21:02:12

Nginx作为反向代理支持5000并发---奇点时代的相关文章

nginx使用反向代理支持node.js服务

前言 Node.js自身能作为web服务器用,但是如果要在一台机器上开启多个Node.js应用该如何做呢?有一种答案就是使用nginx做反向代理.反向代理在这里的作用就是,当代理服务器接收到请求,将请求转发到目的服务器,然后获取数据后返回. 步骤 一.正常使用node.js开启web服务 var http = require('http'); http.createServer(function (request, response) { response.writeHead(200, {'Co

nginx配置反向代理支持session

Nginx反向代理tomcat,很是方便,但是也有些细节的问题需要注意:今天遇到了这样一个问题,tomcat中路径"host/web1",nginx中直接"host/"代理,这时候session就无法正常进行了. 问题描述: 登录后. 跳转http://127.0.0.1:8080/api/index.do 可以正常访问 nginx 反向代理 proxy_pass  http://192.168.1.12:8080/api/ 登录之后跳转   http://api.

NGINX如何反向代理Tomcat并且实现Session保持

简介 LNMT=Linux+Nginx+MySQL+Tomcat: Tomcat 服务器是一个免费的开放源代码的Web 应用服务器,属于轻量级应用服务器: 在中小型系统和并发访问用户不是很多的场合下被普遍使用,是开发和调试JSP 程序的首选: 架构需求 Tomcat实现JSP动态请求解析的基本架构 说明:由后端Tomcat负责解析动态jsp请求,但为了提高响应性能,在同一主机内配置Nginx做反向代理,转发所有请求至tomcat即可: 完整的LNMT架构设计 说明:本篇博客主要讲解单台Hapro

Nginx实现反向代理负载均衡与静态缓存

介绍: Nginx是一款轻量级的Web服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器.在连接高并发的情况下,Nginx是Apache服务器不错的替代品,能够支持高达50000个并发连接数的响应. 实验环境: Hostname IP 系统 规划 n2.preferred 192.168.1.2 Centos 6.5 Web server n3.preferred 192.168.1.3 Centos 6.5 Web server n6.preferred 192.168.1.6

九爷带你了解 nginx 的反向代理

1.1 反向代理初印象 反向代理(Reverse Proxy)方式是指以代理服务器来接受internet上的连接请求,然后将请求转发给内部网络上的服务器,并将从服务器上得到的结果返回给internet上请求连接的客户端,此时代理服务器对外就表现为一个服务器. 从上图可以看出:反向代理服务器位于网站机房,代理网站Web服务器接收Http请求,对请求进行转发. 1.2 反向代理的作用 ①保护网站安全:任何来自Internet的请求都必须先经过代理服务器: ②通过配置缓存功能加速Web请求:可以缓存真

Nginx构建反向代理缓存服务器

防伪码:曾经沧海难为水,除却巫山不是云. 代理服务可简单的分为正向代理和反向代理: 正向代理: 用于代理内部网络对Internet的连接请求(如VPN/NAT),客户端指定代理服务器,并将本来要直接发送给目标Web服务器的HTTP请求先发送到代理服务器上,然后由代理服务器去访问Web服务器, 并将Web服务器的Response回传给客户端:  反向代理: 与正向代理相反,如果局域网向Internet提供资源,并让Internet上的其他用户可以访问局域网内资源, 也可以设置一个代理服务器, 它提

nginx配置反向代理概述

一.nginx反向代理:Web服务器的调度器 1.反向代理(Reverse Proxy)方式是指以代理服务器来接受客户端的连接请求,然后将请求转发给网络上的web服务器(可能是apache.nginx.tomcat.iis等),并将从web服务器上得到的结果返回给请求连接的客户端,此时代理服务器对外就表现为一个服务器. 图上可以看出:反向代理服务器代理网站Web服务器接收Http请求,对请求进行转发.而且nginx作为反向代理服务器可以根据用户请求的内容把请求转发给后端不同的web服务器,例如静

nginx web+反向代理 的配置介绍

user  www;   #定义Nginx运行的用户和用户组 worker_processes  2;  #nginx进程数,建议设置为等于CPU总核心数. #error_log  logs/error.log;     全局错误日志定义类型 #error_log  logs/error.log  notice; #error_log  logs/error.log  info; #pid        logs/nginx.pid;    进程文件 events {  工作模式与连接数上限 w

Nginx + Tomcat 反向代理 负载均衡 集群 部署指南

转载请注明出处:http://blog.csdn.net/smartbetter/article/details/53535435 Nginx是一种服务器软件,也是一种高性能的http和反向代理服务器,同时还是一个代理邮件服务器.也就是说,我们在Nginx上可以发布网站,可以实现负载均衡(提高应答效率,避免服务器崩溃),还可以作为邮件服务器实现收发邮件等功能.而最常见的就是使用Nginx实现负载均衡. Nginx与其他服务器的性能比较: Tomcat服务器面向Java语言,是重量级的服务器,而N