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

      

  • 相关阅读:
    程序员面试金典-面试题 16.15. 珠玑妙算
    程序员面试金典-面试题 16.14. 最佳直线
    程序员面试金典-面试题 16.13. 平分正方形
    程序员面试金典-面试题 16.11. 跳水板
    程序员面试金典-面试题 16.10. 生存人数
    程序员面试金典-面试题 16.08. 整数的英语表示
    程序员面试金典-面试题 16.07. 最大数值
    程序员面试金典-面试题 16.06. 最小差
    python学习笔记-47 UDP编程
    python学习笔记-46 TCP编程
  • 原文地址:https://www.cnblogs.com/rsapaper/p/9989442.html
Copyright © 2020-2023  润新知