xác thực google maps

Xin cách sửa lỗi 502, 524 ở nginx

Thảo luận trong 'Hỗ trợ Domain, Hosting, Server' bắt đầu bởi Adin, 18 Tháng mười một 2016.

Lượt xem: 5,551

  1. Adin

    Adin Dự bị

    Bài viết:
    36
    Đã được thích:
    1
    Chào các bác. Em có cái website lúc nào cao điểm thì được 800 realtime. Còn ngày bình thường thì >600 ạ.
    Em có cài script vpssim trên vps 4 core, 8gb ram nhưng thỉnh thoảng cứ bị lỗi 502 và 524 ạ. Phiền bác nào xem hộ em cái phần cấu hình nginx và php fpm với ạ. Trước có nhờ người khác cấu hình hộ. Giờ em tự nâng cấp nên vẫn còn gà mờ. Nên ai giúp em với ạ
     
  2. Snail

    Snail Dự bị

    Bài viết:
    33
    Đã được thích:
    13
    4 core, 8GB thì thừa sức cõng 800 người truy cập cùng lúc nếu tối ưu vps và mã nguồn tốt.
    Lỗi 502 thì có thể là do vps bị quá tải, 524 thì có thể do nghẽn băng thông, đường truyền hoặc do sử dụng CDN. Bạn dùng vps của nhà nào thế ?

    Thử config lại phần này trong nginx . conf xem :
    Mã:
    fastcgi_buffers 64 64k;
    fastcgi_buffer_size 64k;
    Mà tốt nhất bạn post cái cấu hình file nginx . conf của bạn lên đây thì mọi người mới biết đường mà xem chứ :D

    Thế quái nào viết nginx . conf cũng bị xem là 1 đg link, mấy bác ad sửa lại đc ko nhỉ.
     
    Mr.N2, Adin and quannhvn like this.
  3. Adin

    Adin Dự bị

    Bài viết:
    36
    Đã được thích:
    1
    Mã:
    user  nginx;
    worker_processes  4;
    #worker_priority -10;
    worker_rlimit_nofile 100000;
    
    timer_resolution 100ms;
    pcre_jit on;
    
    error_log  /var/log/nginx/error . log crit;
    pid        /var/run/nginx . pid;
    
    
    events {
        worker_connections  4096;
        use epoll;
        #accept_mutex on;
        #accept_mutex_delay 200ms;
        multi_accept on;
    }
    
    
    http {
        include       /etc/nginx/mime . types;
        default_type  application/octet-stream;
    include /etc/nginx/conf/ddos1 . conf;
        log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                          '$status $body_bytes_sent "$http_referer" '
                          '"$http_user_agent" "$http_x_forwarded_for"';
    more_set_headers    "Server: Nginx";
    more_set_headers "X-Powered-By: VPSSIM"
        access_log  off;
        sendfile on;
        sendfile_max_chunk 512k;
        tcp_nopush on;
        tcp_nodelay on;
        types_hash_max_size 2048;
        server_tokens off;
        server_name_in_redirect off;
        server_names_hash_bucket_size 128;
        open_file_cache max=130000 inactive=20s;
        open_file_cache_valid 30s;
        open_file_cache_min_uses 2;
        open_file_cache_errors off;
        open_log_file_cache max=10000 inactive=30s min_uses=2;
        output_buffers   8 256k;
        postpone_output  1460;
        request_pool_size  32k;
      
        connection_pool_size  512;
        directio 4m;
      
    
        client_body_buffer_size 256k;
        client_body_timeout 50;
        client_header_buffer_size 64k;
        client_body_in_file_only off;
        large_client_header_buffers 4 256k;
        client_header_timeout  15;
        ignore_invalid_headers on;
        client_max_body_size 120m;
      
      
        keepalive_timeout 20;
        keepalive_requests 1000;
        keepalive_disable msie6;
        lingering_time 20s;
        lingering_timeout 5s;
        reset_timedout_connection on;
        send_timeout 50;
      
      
        gzip on;
        gzip_static on;
        gzip_disable "msie6";
        gzip_vary on;
        gzip_proxied any;
        gzip_comp_level 5;
        gzip_buffers 32 8k;
        gzip_min_length 1024;
        gzip_http_version 1 . 1;
        gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
    
    
      # Cloudflare module cho nginx
        set_real_ip_from   204 . 93 . 240 . 0/24;
        set_real_ip_from   204 . 93 . 177 . 0/24;
        set_real_ip_from   199 . 27 . 128 . 0/21;
        set_real_ip_from   173 . 245 . 48 . 0/20;
        set_real_ip_from   103 . 21 . 244 . 0/22;
        set_real_ip_from   103 . 22 . 200 . 0/22;
        set_real_ip_from   103 . 31 . 4 . 0/22;
        set_real_ip_from   141 . 101 . 64 . 0/18;
        set_real_ip_from   108 . 162 . 192 . 0/18;
        set_real_ip_from   190 . 93 . 240 . 0/20;
        set_real_ip_from   188 . 114 . 96 . 0/20; 
        set_real_ip_from   197 . 234 . 240 . 0/22;
        set_real_ip_from   198 . 41 . 128 . 0/17;
        real_ip_header     CF-Connecting-IP;
    
        upstream fastcgi_backend {
         least_conn;
         server unix:/var/run/php-fpm/php-fpm . sock1 weight=100 max_fails=2 fail_timeout=5;
         server unix:/var/run/php-fpm/php-fpm . sock2 weight=100 max_fails=2 fail_timeout=5;
         server unix:/var/run/php-fpm/php-fpm . sock3 weight=100 max_fails=2 fail_timeout=5;
         server unix:/var/run/php-fpm/php-fpm . sock4 weight=100 max_fails=2 fail_timeout=5;
         server unix:/var/run/php-fpm/php-fpm . sock5 weight=100 max_fails=2 fail_timeout=5;
         server unix:/var/run/php-fpm/php-fpm . sock6 weight=100 max_fails=2 fail_timeout=5;
         server unix:/var/run/php-fpm/php-fpm . sock7 weight=100 max_fails=2 fail_timeout=5;
         server unix:/var/run/php-fpm/php-fpm . sock8 weight=100 max_fails=2 fail_timeout=5;
         server unix:/var/run/php-fpm/php-fpm . sock9 weight=100 max_fails=2 fail_timeout=5;
         server unix:/var/run/php-fpm/php-fpm . sock10 weight=100 max_fails=2 fail_timeout=5;
         server 127 . 0 . 0 . 1:9000 backup;
        }
        fastcgi_buffers 16 32k;
        fastcgi_buffer_size 32k;
        fastcgi_connect_timeout 300;
        fastcgi_send_timeout    300;
        fastcgi_read_timeout    300;
      
        include /etc/nginx/conf . d/* . conf;
    }
    
    đây bác ạ. Bác xem với ạ. Em trước chỉ dùng apache. Giờ mới tìm hiểu nginx, thường thì lâu lâu bị lần. Nhưng dạo này bị liên tục ạ :(

    có bác nào đang dùng cloudflare không ạ? Hình như nó đang có vấn đề gì đấy :(.
     
  4. duyvo

    duyvo Dự bị

    Bài viết:
    17
    Đã được thích:
    0
    Mình dùng cloudflare vẫn thấy bình thường bạn à, bạn thử chuyển qua xài centminmod đi xem có cài thiện khả năng chịu tải không
     

Chia sẻ trang này