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;

worker_rlimit_nofile 65535;
events {
    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;
 
 
 
    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    #server {
        #listen       80;
        #server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

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

        #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 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;
    #    }
    #}
 upstream tomcat8091 {
     server 172.16.0.130:8091; 
  server 172.16.0.131:8091;
  }
  upstream tomcat8092 {
     server 172.16.0.130:8092; 
  server 172.16.0.131:8092;
  }
 server {  
       listen  8091;  
       location / {  
           root   html;  
            index  index.html index.htm;  
            proxy_pass http://tomcat8091;
   proxy_set_header  X-Real-IP  $remote_addr;  
            client_max_body_size  100m;

        }   
  
    }  
 server {  
       listen      8092;  
       location / {  
           root   html;  
            index  index.html index.htm;  
            proxy_pass http://tomcat8092
   proxy_set_header  X-Real-IP  $remote_addr;  
           client_max_body_size  100m;

        }  
  location ~ \.(jpg|png|gif)$ {
           proxy_pass  
http://172.16.0.130:8092;   #图片指定一个地址中
        }  
  
    } 

 
 
}

 本文转自 jxzhfei  51CTO博客,原文链接:http://blog.51cto.com/jxzhfei/1553625


相关文章
|
5月前
|
负载均衡 应用服务中间件 Linux
Nginx系列教程(14) - LVS+KeepAlived+Nginx实现高性能负载均衡集群
Nginx系列教程(14) - LVS+KeepAlived+Nginx实现高性能负载均衡集群
178 0
|
1月前
|
前端开发 应用服务中间件 nginx
nginx中配置不输入端口(指定地址)访问项目的方法
nginx中配置不输入端口(指定地址)访问项目的方法
23 0
|
8月前
|
运维 负载均衡 中间件
【运维知识进阶篇】集群架构-Nginx动静分离详解
【运维知识进阶篇】集群架构-Nginx动静分离详解
64 0
|
8月前
|
运维 关系型数据库 MySQL
【运维知识进阶篇】集群架构-Nginx实现基础web架构(Linux+Nginx+PHP+Mysql)(二)
【运维知识进阶篇】集群架构-Nginx实现基础web架构(Linux+Nginx+PHP+Mysql)(二)
202 0
|
8月前
|
运维 监控 网络协议
【运维知识进阶篇】集群架构-Nginx常用模块(目录索引+状态监控+访问控制+访问限制)(下)
【运维知识进阶篇】集群架构-Nginx常用模块(目录索引+状态监控+访问控制+访问限制)(下)
58 0
|
5月前
|
应用服务中间件 Apache nginx
nginx做反向代理导致request.getServerName()获取不到代理地址的问题
nginx做反向代理导致request.getServerName()获取不到代理地址的问题
|
7月前
|
Kubernetes 应用服务中间件 Linux
CentOS7上搭建Kubernetes(K8S)集群并部署nginx(kubeadm方式)
CentOS7上搭建Kubernetes(K8S)集群并部署nginx(kubeadm方式)
303 1
|
8月前
|
存储 负载均衡 应用服务中间件
nginx与IIS服务器搭建集群实现负载均衡(三)
nginx与IIS服务器搭建集群实现负载均衡(三)
155 1
|
8月前
|
人工智能 负载均衡 应用服务中间件
nginx与IIS服务器搭建集群实现负载均衡(二)
nginx与IIS服务器搭建集群实现负载均衡(二)
125 1
|
8月前
|
人工智能 负载均衡 大数据
nginx与IIS服务器搭建集群实现负载均衡(一)
nginx与IIS服务器搭建集群实现负载均衡(一)
137 0