`

nginx负载均衡配置实例

 
阅读更多

#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 {
    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  backend {
#ip_hash;
server   192.168.0.21:8099;
server   192.168.0.205:7080;
#server   192.168.0.26:80;
    }



    server {
        listen       8888;
        server_name  192.168.0.26;
#server_name  127.0.0.1;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
    #root  D:/web;
            index  index.html index.htm;

    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;
    proxy_pass  http://backend;
        }

        #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;
        }

        # 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  ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
    #    ssl_prefer_server_ciphers   on;

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

}
分享到:
评论

相关推荐

    nginx负载均衡配置文件实例

    **Nginx负载均衡配置详解** Nginx是一款高性能的HTTP和反向代理服务器,它以其轻量级、高并发的特性在Web服务领域广泛应用。其中,Nginx的负载均衡功能是其重要特性之一,它能有效地分散网络流量,提高系统可用性和...

    Nginx实现负载均衡 web均衡负载 webservice负载均衡 Nginx实现负载均衡配制全说明

    Nginx实现负载均衡 web均衡负载 webservice负载均衡 Nginx实现负载均衡配制全说明 为了多台后台的web、webservice服务能均衡负载,可以使用nginx进行处理 1)配置文件全配制ok 2)有两个完整的web服务做例子,可以...

    Nginx负载均衡配置

    下面详细解释Nginx负载均衡的配置方法以及负载均衡策略。 首先,要配置Nginx与Tomcat实现负载均衡,需要准备两个Tomcat实例,每个实例可以部署一个简单的Web项目,例如通过在页面上标注不同的端口号,以便区分它们...

    Nginx+tomcat配置集群负载均衡实例

    本实例将详细阐述如何通过Nginx配置集群负载均衡,以实现动静分离,提升系统性能和稳定性。 首先,Nginx是一款轻量级的Web服务器/反向代理服务器,以其高性能、稳定性以及低内存占用著称。它能处理静态文件请求,...

    redis+tomcat+nginx负载均衡配置

    在构建高性能、高可用性的Web服务时,"redis+tomcat+nginx负载均衡配置"是一个常见且有效的架构模式。这个组合充分利用了各个组件的优势,确保系统稳定、响应快速,并能够处理大量的并发请求。以下是关于这个配置的...

    nginx负载均衡代理多个tomcat搭建实例过程

    本节主要介绍Nginx负载均衡配置。 1.2.3 Nginx配置 在nginx.conf文件中添加负载均衡配置,例如: upstream tomcat { server localhost:8080 weight=1; server localhost:8081 weight=1; } 四、压力测试 本节...

    三步安装完成nginx负载均衡设置.docx

    在进行 Nginx 负载均衡配置之前,我们需要确保有一个适合运行 Nginx 的环境。这通常涉及到以下几个方面: 1. **Java 环境**:由于某些应用可能依赖 Java,因此在 Tomcat 服务器上需要预先安装 JDK。这包括下载并...

    nginx+eureka实现负载均衡实例

    本实例将讲解如何结合 `nginx` 和 `Eureka` 实现微服务的负载均衡,从而提高网站的访问性能。 1. **Nginx 负载均衡** - **工作原理**:Nginx 可以根据预设的策略(如轮询、最少连接、IP哈希等)将请求分发到多个...

    nginx负载均衡配置

    ### Nginx负载均衡配置详解 #### 一、前言 Nginx 是一款轻量级的 Web 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,并在一个BSD-like 协议下发行。其特点是占有内存少,并发能力强,事实上 Nginx 的...

    nginx负载均衡 nginx+tomcat tomcat实现负责均衡

    ### Nginx与Tomcat实现负载均衡的知识点详解 #### Nginx简介及特性 Nginx是一款由Igor Sysoev开发的高性能HTTP服务器和反向代理服务器,以其出色的稳定性和低系统资源消耗而著称。最初是为俄罗斯访问量排名第二的...

    【Nginx】Windows平台下配置Nginx服务实现负载均衡.doc

    ### Nginx在Windows平台下的负载均衡配置详解 #### 一、引言 负载均衡是现代Web应用架构中不可或缺的一部分,它可以有效提升系统的可用性和扩展性。本文将详细介绍如何在Windows平台上利用Nginx实现负载均衡,特别...

    Nginx+Tomcat 负载均衡 3分钟搞定

    要实现负载均衡,需要在 Nginx 服务器上配置 upstream 模块,以便将请求分配到多台 Tomcat 服务器上。具体配置如下: 1. upstream netitcast.com { server 127.0.0.1:18080 weight=1; server 127.0.0.1:28080 ...

    Nginx与Tomcat配置实现负载均衡.zip

    以下是配置Nginx负载均衡的基本步骤: 1. **安装Nginx**:在你的服务器上安装Nginx,确保它能够正常启动和运行。 2. **配置Nginx**:打开Nginx的配置文件(通常为`/etc/nginx/nginx.conf`或`/usr/local/nginx/conf...

    Nginx与tomcat 负载均衡

    6. 配置Nginx来实现负载均衡 四、Nginx配置 * 工作进程的个数(worker_processes)设置为1,与计算机的CPU核数一致 * 单个进程的最大连接数(worker_connections)设置为1024 * 文件扩展名与文件类型映射表(mime....

    Nginx负载均衡Tomcat简单配置

    **Nginx负载均衡Tomcat简单配置** 在大型的Web应用系统中,为了提高服务的可用性和响应速度,通常会采用负载均衡技术。Nginx作为一款高性能的反向代理服务器,常被用来实现对后端多台Tomcat服务器的负载均衡。本篇...

    nginx负载均衡教程

    #### 三、Nginx负载均衡配置示例 根据提供的部分内容,我们详细解析如何配置Nginx进行负载均衡: ##### 1. 单独使用一台Nginx做负载均衡 **配置文件示例**: ```nginx upstream local_tomcat { ip_hash; ...

    Nginx + Tomcat 负载均衡配置详解

    **Nginx + Tomcat 负载均衡配置详解** 在现代互联网应用中,服务器的高可用性和性能优化是至关重要的。Nginx 和 Tomcat 的组合常常被用来实现这样的目标,其中Nginx作为反向代理和负载均衡器,而Tomcat作为Java应用...

    Nginx负载均衡集群配置文档

    本文档将深入探讨如何配置Nginx来实现对Tomcat应用服务器的负载均衡,以提高系统的稳定性和效率。 一、Nginx简介 Nginx以其轻量级的进程模型、高效的并发处理能力以及丰富的模块化设计,成为部署静态资源和代理服务...

    NGINX-配置手册

    - [Nginx负载均衡配置实例](http://www.cnblogs.com/knowledgesea/p/5157565.html) #### 四、运行环境 **硬件环境:** - CPU: 至少双核处理器 - 内存: 至少4GB RAM - 存储空间: 至少20GB可用空间 **软件环境:** ...

Global site tag (gtag.js) - Google Analytics