zoukankan      html  css  js  c++  java
  • Nginx配置记录【例2】

    B服务器,例:

    [root@localhost conf.d]# egrep -v "^#|^$" /etc/nginx/nginx.conf

    user nginx;
    worker_processes 8;
    error_log /var/log/nginx/error.log;
    pid /var/run/nginx.pid;
    worker_rlimit_nofile 65520;
    include /usr/share/nginx/modules/*.conf;
    events {
        use epoll;
        worker_connections  10240;
    }
    http {
        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  /var/log/nginx/access.log  main;
        sendfile            on;
        tcp_nopush          on;
        tcp_nodelay         on;
        keepalive_timeout   65;
        types_hash_max_size 2048;
        #gzip 压缩传输
        gzip on;
        gzip_min_length 1k;  #最小1K
        gzip_buffers 16 64K;
        #gzip_http_version 1.1;
        gzip_comp_level 6;
        gzip_types text/plain application/x-javascript text/css application/xml application/javascript image/jpeg image/gif image/png;
        gzip_vary on;
        include             /etc/nginx/mime.types;
        default_type        application/octet-stream;
        proxy_intercept_errors on;
        proxy_redirect off;
        #proxy_set_header Host $host;
        proxy_set_header Host $host:$server_port;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        client_max_body_size 10m;
        client_body_buffer_size 328k;
        proxy_connect_timeout 90;
        proxy_read_timeout 90;
        proxy_send_timeout 90;
        proxy_buffer_size 40k;
        proxy_buffers 4 320k;
        proxy_busy_buffers_size 640k;
        proxy_temp_file_write_size  640k;  
        # Load modular configuration files from the /etc/nginx/conf.d directory.
        # See http://nginx.org/en/docs/ngx_core_module.html#include
        # for more information.
        include /etc/nginx/conf.d/*.conf;
    }
    

    [root@localhost conf.d]# ls
    chandao.conf cmsapitest.conf shtest.conf 

    [root@localhost conf.d]# more chandao.conf

    server {
        listen       8079;
        server_name  chandao.abc.com;
    
        location / {
             proxy_pass http://192.xxx.xxx.43:9090/;
        }
    
        location = /favicon.ico {
            log_not_found off;
            access_log off;
        } 
    
        error_page 404 http://chandao.abc.com:8079;
        error_page 500 502 503 504 http://chandao.abc.com:8079;
    }
    
    # 不允许IP地址直接访问
    server {
      listen 8079 default;
      server_name _;
      return 403;
    }
    

    [root@localhost conf.d]# more cmsapitest.conf 

    server {
        listen       8079;
        server_name  cmsapitest.abc.com;
    
        location / {
             proxy_pass http://192.xxx.xxx.43:8078/;
        }
    
        location = /favicon.ico {
            log_not_found off;
            access_log off;
        } 
    
        error_page 404 http://cmsapitest.abc.com:8079;
        error_page 500 502 503 504 http://cmsapitest.abc.com:8079;
    
    }
    

    [root@localhost conf.d]# more gw.conf 

    server {
        listen       8089;
        server_name _;
        root /var/www/lwgw;
    
        location / {
           root /var/www/lwgw/gw;
           try_files $uri /index.html;
           expires 1m;
        }
    
        location ^~ /actives {
           try_files $uri $uri/ /actives/index.html;
           expires 1m;
        }
    
        location ^~ /activeBargain {
           try_files $uri $uri/ /activeBargain/index.html;
           expires 1m;
        }
    
    #    location ^~ /gw-mobile {
    #       try_files $uri $uri/ /gw-mobile/index.html;
    #       expires 1m;
    #    }
    
        location ^~ /active/pc {
           try_files $uri $uri/ /active/pc/index.html;
           expires 1m;
        }
        
        location ^~ /active/mobile {
           try_files $uri $uri/ /active/mobile/index.html;
           expires 1m;
        }
    
        location /api {
           proxy_pass http://218.xxx.xxx.42:8088/;
        }
    
        location /activeApi {
           proxy_pass http://218.xxx.xxx.42:8088/;
        }
    
        location /getTitleApi {
           proxy_pass http://218.xxx.xxx.44:9993/;
        }
    
        location /wxApi {
           proxy_set_header Host api.weixin.qq.com;
           rewrite /wxApi/(.+)$ /$1 break;
           proxy_pass https://api.weixin.qq.com;
        }
    
        location /wx {
           proxy_set_header Host api.weixin.qq.com;
           rewrite /wx/(.+)$ /$1 break;
           proxy_pass https://api.weixin.qq.com;
        }
       
       location /up {
           rewrite "^/up/(.*)$" http://218.xxx.xxx.42:8088/up/$1;
           expires 1d;
        }
    
       location /bargainBaseUrl {
           proxy_pass http://218.xxx.xxx.42:8078/;
        }
      
        location = /favicon.ico {
            log_not_found off;
            access_log off;
        } 
    
        error_page 404 http://218.xxx.xxx.42:8089;
        error_page 500 502 503 504 http://218.xxx.xxx.42:8089;
    
    }
    

      

  • 相关阅读:
    微信中一些常用的js事件积累
    css 设置圆角
    移动开发可能用到的css单位
    移动端触摸划屏,实现内容滑动
    postman发送get请求
    Jmeter 快速入门初识线程组
    python基础(一)简单入门
    Jmeter 快速入门简单的http压测
    Mac下Git的基础操作
    接口测试基础
  • 原文地址:https://www.cnblogs.com/eos666/p/11818388.html
Copyright © 2011-2022 走看看