zoukankan      html  css  js  c++  java
  • ngInx 配置多个server

    nginx 配置多个server:
    
    events
        {
            use epoll;
            worker_connections 65535;
            multi_accept on;
        }
    
    http
        {
            include       mime.types;
            default_type  application/octet-stream;
    
            server_names_hash_bucket_size 256;
            client_header_buffer_size 256k;
            large_client_header_buffers 4 256k;
            client_max_body_size 128m;
            client_body_buffer_size 16m;
    
     fastcgi_buffer_size 256k;
     fastcgi_buffers 256 16k;
     fastcgi_busy_buffers_size 256k;
     fastcgi_temp_file_write_size 256k;
     
     proxy_buffering on;
     proxy_buffer_size 1024k;
     proxy_buffers 32 8192k;
     proxy_busy_buffers_size 16384k;
     
            sendfile   on;
            tcp_nopush on;
    
            keepalive_timeout 120s;
     keepalive_requests 30000;
     reset_timedout_connection on;
     client_body_timeout 3m;
    
            tcp_nodelay on;
    
            gzip on;
            gzip_min_length  16k;
            gzip_buffers     8 32k;
            gzip_http_version 1.1;
            gzip_comp_level 4;
            gzip_types     text/plain application/javascript application/x-javascript text/javascript text/css application/xml application/xml+rss;
            gzip_vary on;
            gzip_proxied   expired no-cache no-store private auth;
            gzip_disable   "MSIE [1-6].";
    
            server_tokens off;
           
            log_format  access  '$remote_addr - $remote_user [$time_local] "$request" '
                 '$status $body_bytes_sent "$http_referer" '
                 '"$http_user_agent" $http_x_forwarded_for';
     #access_log off;
    
     upstream backend1 {
        server 192.168.137.3:9000  max_fails=2 fail_timeout=30s;
       
    }
    
     upstream backend2 {
        server 192.168.137.3:8090     max_fails=2 fail_timeout=30s;
       
    }
    
    
     upstream backend3 {
        server 192.168.137.3:8090     max_fails=2 fail_timeout=30s;
        server 192.168.137.3:9000  max_fails=2 fail_timeout=30s;
        
    }
    
    ##upstream backend 位置放错了, upstream位置应该放在http模块里面 但必须是在server模块的外面
    
     server
     {
     listen 9080 default_server backlog=1024;
     #server_name paytest.zjtlcb.com;
     index index.html index.htm;
     #root  /app/weblogic/html/;
     #root  /app_nas/apps/deploy/html/;
    
               location /nginx_status  {
     stub_status on;
     access_log off;
     allow 1.2.101.1;
     allow 1.2.101.2;
     allow 1.2.101.3;
     allow 1.2.101.4;
     allow 1.2.101.5;
     allow 1.2.101.6;
     allow 1.2.101.7;
     allow 1.2.101.8;
     deny all;
     }
    
    
    
    
    
    
     location ^~ /bbb 
     {
    proxy_pass http://backend1/;
     proxy_connect_timeout 300;
     proxy_send_timeout 300;
     proxy_read_timeout 300;
      proxy_set_header   Host             $host;
     proxy_set_header   X-Real-IP        $remote_addr;       
     proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
     }
    
     }
     
      server
     {
     listen 9090 default_server backlog=1024;
     #server_name paytest.zjtlcb.com;
     index index.html index.htm;
     #root  /app/weblogic/html/;
     #root  /app_nas/apps/deploy/html/;
    
               location /nginx_status  {
     stub_status on;
     access_log off;
     allow 1.2.101.1;
     allow 1.2.101.2;
     allow 1.2.101.3;
     allow 1.2.101.4;
     allow 1.2.101.5;
     allow 1.2.101.6;
     allow 1.2.101.7;
     allow 1.2.101.8;
     deny all;
     }
    
    
    
    
    
    
     location ^~ /bbb 
     {
    proxy_pass http://backend2/;
     proxy_connect_timeout 300;
     proxy_send_timeout 300;
     proxy_read_timeout 300;
      proxy_set_header   Host             $host;
     proxy_set_header   X-Real-IP        $remote_addr;       
     proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
     }
    
     }
     
     
     #include vhost/*.conf;
    }
    
    
    
    
    node1:/etc/nginx#netstat -nap |grep 90
    tcp        0      0 0.0.0.0:9080                0.0.0.0:*                   LISTEN      4185/nginx          
    tcp        0      0 0.0.0.0:9090                0.0.0.0:*                   LISTEN      4185/nginx  
    
    
    
    访问http://192.168.137.2:9080/bbb  到devops 页面
    
    
    访问http://192.168.137.2:9090/bbb  到demo 页面
    
  • 相关阅读:
    [ jquery 选择器 :hidden ] 此方法选取匹配所有不可见元素,或者type为hidden的元素
    剑指 Offer 03. 数组中重复的数字 哈希
    LeetCode 1736. 替换隐藏数字得到的最晚时间 贪心
    Leetcode 1552. 两球之间的磁力 二分
    Leetcode 88. 合并两个有序数组 双指针
    LeetCode 1744. 你能在你最喜欢的那天吃到你最喜欢的糖果吗?
    LeetCode 1743. 相邻元素对还原数组 哈希
    LeetCode 1745. 回文串分割 IV dp
    剑指 Offer 47. 礼物的最大价值 dp
    剑指 Offer 33. 二叉搜索树的后序遍历序列 树的遍历
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13348402.html
Copyright © 2011-2022 走看看