zoukankan      html  css  js  c++  java
  • nginx分发请求的2种方式:1、指明server_name;2、通过location过滤uri来分发请求;

    user  nginx;
    worker_processes  8; # = cpu num;
    
    error_log  /data/nginx/log/error/error.log warn; # warn, error crit, alert, and emerg levels are logged.  NGINX Docs | Configuring Logging https://docs.nginx.com/nginx/admin-guide/monitoring/logging/
    
    #pid        logs/nginx.pid;
    
    
    events {
        worker_connections  10240;
        multi_accept on;
        use epoll;
    }
    
    
    http {
        # log  NGINX Docs | Configuring Logging https://docs.nginx.com/nginx/admin-guide/monitoring/logging/
        log_format compression '$http_host - $remote_addr - $remote_user [$time_local] '
                               '"$request" $status $body_bytes_sent '
                               '"$http_referer" "$http_user_agent" "$gzip_ratio"';
        gzip on;
        access_log /data/nginx/log/access/nginx-access.log compression;
    
        include       mime.types;
        default_type  application/octet-stream;
    
        server_tokens off;
            sendfile on;
            tcp_nopush on;
            tcp_nodelay on;
            keepalive_timeout 10;
            client_header_timeout 10;
            client_body_timeout 10;
            reset_timedout_connection on;
            send_timeout 10;
            limit_conn_zone $binary_remote_addr zone=addr:5m;
            limit_conn addr 100;
            charset UTF-8;
    
        open_file_cache max=100000 inactive=20s;
            open_file_cache_valid 30s;
            open_file_cache_min_uses 2;
            open_file_cache_errors on;
            client_max_body_size 151M;
    
        server {
            listen       80;
            location  ~ ^/visit/index?.+$ {
               proxy_pass http://1.2.19.19:18080;
                       access_log /data/nginx/log/access/nginx-access-proxy_pass.log compression;
            }
        }
    # 分发请求的2种方式:1、指明server_name;2、通过location过滤uri来分发请求;
            server {
                    listen       80;
                    server_name  localhost;
    
                    #charset koi8-r;
                    #access_log  logs/host.access.log  main;
    
                    root   /var/www/statistics_20170105/public;
    
                    location / {
                        index  index.php index.html index.htm;
                        if (!-e $request_filename) {
                            rewrite ^/(.*)  /index.php?$1 last;
                        }
                    }
    
                    #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;
                    }
                    location ~ .php$ {
                            fastcgi_pass   127.0.0.1:9000;
                            fastcgi_index  index.php;
                            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                            include        fastcgi_params;
    
                    }
            }
            server {
                    listen       80;
                    server_name  per.go-old.com;
    
                    #charset koi8-r;
                    #access_log  logs/host.access.log  main;
    
                    root   /var/www/opcenter/public;
    
                    location / {
                        index  index.php index.html index.htm;
                        if (!-e $request_filename) {
                            rewrite ^/(.*)  /index.php?$1 last;
                        }
                    }
    
                    #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;
                    }
                    location ~ .php$ {
                            fastcgi_pass   127.0.0.1:9000;
                            fastcgi_index  index.php;
                            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                            include        fastcgi_params;
    
                    }
            }
            server {
                    listen       80;
                    server_name  yzt.go-old.com pay.go-old.com xmt.go-old.com;
    
                    #charset koi8-r;
                    #access_log  logs/host.access.log  main;
    
                    root   /var/www/yzt/public;
    
                    location / {
                        index  index.php index.html index.htm;
                        if (!-e $request_filename) {
                            rewrite ^/(.*)  /index.php?$1 last;
                        }
                    }
    
                    #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;
                    }
                    location ~ .php$ {
                            fastcgi_pass   127.0.0.1:9000;
                            fastcgi_index  index.php;
                            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                            include        fastcgi_params;
    
                    }
            }
    }
    

      

  • 相关阅读:
    适配器模式(2)
    设计模式之6大设计原则(1)
    Mybatis框架基础支持层——反射工具箱之MetaClass(7)
    Mybatis框架基础支持层——反射工具箱之实体属性Property工具集(6)
    Mybatis框架基础支持层——反射工具箱之对象工厂ObjectFactory&DefaultObjectFactory(5)
    Mybatis框架基础支持层——反射工具箱之泛型解析工具TypeParameterResolver(4)
    Guava动态调用方法
    数据库的数据同步
    springboot(二十二)-sharding-jdbc-读写分离
    springboot(二十一)-集成memcached
  • 原文地址:https://www.cnblogs.com/rsapaper/p/9989442.html
Copyright © 2011-2022 走看看