2016-11-23 88 views
0

我們使用NGINX作爲反向代理來整合到網站。所有請求都會根據網址轉發到一個網站或另一個網站。由於額外的「啤酒花」,我們預計會有小的性能損失,但性能非常糟糕。加載css,js和圖片每個資源需要1-2秒。 NGINX服務器是< 1%的CPU負載。NGINX作爲反向代理減速網站太多

如果我使用Firebug調查我看到了巨大的塊和等待時間在網板:Performance via NGINX as reverse proxy

如果我們去了原來的網站,直接,它的速度要快得多(約100毫秒): enter image description here

這個'throtteling'的原因是什麼?

這是我的網站的配置:

server { 
     listen 80; 
     server_name *.mysite.nl; 
     return 301 http://www.mysite.nl$request_uri; 
} 

server { 
    listen 80; 
    root /var/www/; 
    index index.php index.html index.htm index.asp index.aspx; 
    server_name www.mysite.nl; 
    return 301 https://$server_name$request_uri; 
    include includes/mysite.nl-redirects.conf; 

    location/{ 
    return 301 https://$server_name$request_uri; 
    proxy_set_header X-Real-IP $remote_addr; 
    proxy_set_header X-Forwarded-For $remote_addr; 
    proxy_set_header Host $host; 
    proxy_pass http://100.6.185.172:80; 
    proxy_set_header  X-Forwarded-Proto "http"; 
    } 
    location /account { 

    proxy_set_header X-Real-IP $remote_addr; 
    proxy_set_header X-Forwarded-For $remote_addr; 
    proxy_set_header Host $host; 
    proxy_pass http://platform.mysite.nl:80; 
    } 
    location /contentowner { 
    proxy_set_header X-Real-IP $remote_addr; 
    proxy_set_header X-Forwarded-For $remote_addr; 
    proxy_set_header Host $host; 
    proxy_pass http://platform.mysite.nl:80; 
    } 
} 

server { 
     listen 443; 
     root /var/www/; 
     index index.php index.html index.htm index.asp index.aspx; 
     server_name www.mysite.nl; 
     ssl_certificate   /etc/ssl/private/mysite.nl/cert.crt; 
     ssl_certificate_key  /etc/ssl/private/mysite.nl/cert.key; 
     ssl_client_certificate /etc/ssl/private/mysite.nl/ca.crt; 
     ssl on; 
     ssl_session_cache builtin:1000 shared:SSL:10m; 
     ssl_protocols TLSv1 TLSv1.1 TLSv1.2; 
     ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4; 
     ssl_prefer_server_ciphers on; 

    include includes/mysite.nl-redirects.conf; 

     location/{ 
     proxy_set_header  X-Forwarded-Proto "https"; 
     proxy_set_header X-Real-IP $remote_addr; 
     proxy_set_header X-Forwarded-For $remote_addr; 
     proxy_set_header Host $host; 
     proxy_pass https://100.6.185.172:443; 
     } 
     location /account/ { 
     #return 301 http://$server_name$request_uri; 
     proxy_set_header  X-Forwarded-Proto "https"; 
     proxy_set_header X-Real-IP $remote_addr; 
     proxy_set_header X-Forwarded-For $remote_addr; 
     proxy_set_header Host $host; 
     proxy_pass http://platform.mysite.nl:80; 
     } 
     location /contentowner/ { 
     #return 301 http://$server_name$request_uri; 
     proxy_set_header  X-Forwarded-Proto "https"; 
     proxy_set_header X-Real-IP $remote_addr; 
     proxy_set_header X-Forwarded-For $remote_addr; 
     proxy_set_header Host $host; 
     proxy_pass http://platform.mysite.nl:80; 
     } 
} 

這是我nginx.config:

user www-data; 
worker_processes auto; 
pid /run/nginx.pid; 

events { 
     worker_connections 18000; 
     multi_accept on; 
} 

http { 

     ## 
     # Basic Settings 
     ## 

     sendfile on; 
     tcp_nopush off; 
     tcp_nodelay on; 
     keepalive_timeout 65; 
     types_hash_max_size 2048; 
     server_tokens off; 
     client_max_body_size 5M; 
     #proxy_buffering off; 
     #access_log off; 

     # server_names_hash_bucket_size 64; 
     # server_name_in_redirect off; 

     include /etc/nginx/mime.types; 
     default_type application/octet-stream; 

     ## 
     # SSL Settings 
     ## 

     ssl_dhparam /etc/nginx/ssl/dhparam.pem; 
     ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE 
     ssl_prefer_server_ciphers on; 

     ## 
     # Logging Settings 
     ## 

     access_log /var/log/nginx/access.log; 
     error_log /var/log/nginx/error.log; 

     ## 
     # Gzip Settings 
     ## 

     gzip on; 
     gzip_disable "msie6"; 

     gzip_vary on; 
     gzip_proxied any; 
     gzip_comp_level 6; 
     gzip_buffers 16 8k; 
     gzip_http_version 1.1; 
     gzip_min_length 256; 
     gzip_types text/plain text/css application/json application/x-javascript application/javascript text/xml application/xml application$ 

     ## 
     # Virtual Host Configs 
     ## 

     include /etc/nginx/conf.d/*.conf; 
     include /etc/nginx/sites-enabled/*; 
} 

回答

1

您正在使用HTTP/2你原來的服務器上,而不是反向代理。看到您的頁面正在加載的額外資源的數量,這至少是問題的一部分。

+0

太棒了!我們會改變這一點! –

+1

是的,頁面加載的主要改進!謝謝!!! –