我在Docker容器中使用nginx 1.9.2(使用pagespeed和geoIP),在Google容器引擎上运行。 它作为运行php-fpm(php7)的另一个容器的代理。 我也使用fastcgi代理。
我觉得它很慢,所以我开始看着不同的可用graphics,我看到这个内存图:
有人见过这样的事吗? 这是一种常见的模式吗? 实际上是否可以说一个nginxconfiguration文件是“正常的”或不? 如果你是我,你会怎么做?
这是顶部:
Mem: 1352376K used, 392976K free, 0K shrd, 29581464K buff, 29581520K cached CPU: 4% usr 1% sys 0% nic 94% idle 0% io 0% irq 0% sirq Load average: 0.04 0.08 0.10 2/278 55 PID PPID USER STAT VSZ %VSZ %CPU COMMAND 7 1 www-data S 914m 54% 0% nginx: worker process 8 1 www-data S 297m 17% 0% nginx: cache manager process 1 0 root S 288m 17% 0% nginx: master process /usr/sbin/nginx
没有别的东西在容器中运行,只有nginx。
我的nginx conf如下:
https://github.com/vincentserpoul/docker.io/blob/master/vincentserpoul/nginx/etc/nginx/nginx.conf
我的网站configuration如下:
fastcgi_cache_path /etc/nginx/cache levels=1:2 keys_zone=xxxx:100m inactive=60m; fastcgi_cache_key "$scheme$request_method$host$request_uri"; server { root /var/www/xxxx.xx; server_name www.xxxx.xx; access_log /var/log/nginx/access.log main; error_log /var/log/nginx/error.log; listen 443 ssl http2 deferred; # SSL ssl_certificate /etc/nginx/ssl/xxxx.xx.bundle.crt; ssl_certificate_key /etc/nginx/ssl/xxxx.xx.key; ssl_protocols TLSv1.2 TLSv1.1 TLSv1; ssl_prefer_server_ciphers on; ssl_ciphers 'kEECDH+ECDSA+AES128 kEECDH+ECDSA+AES256 kEECDH+AES128 kEECDH+AES256 kEDH+AES128 kEDH+AES256 DES-CBC3-SHA +SHA !aNULL !eNULL !LOW !MD5 !EXP !DSS !PSK !SRP !kECDH !CAMELLIA !RC4 !SEED'; ssl_session_cache shared:SSL:20m; ssl_session_timeout 10m; ssl_dhparam /etc/nginx/ssl/dhparam.pem; ssl_session_tickets off; ssl_stapling on; ssl_stapling_verify on; ssl_trusted_certificate /etc/nginx/ssl/xxxx.xx.full_chain.pem; resolver 8.8.8.8 8.8.4.4 valid=300s; resolver_timeout 5s; # Deny illegal Host headers if ($host !~* \.(xxxx.xx)$ ) { return 444; } include /etc/nginx/conf.d/pagespeed.safe.conf; pagespeed LoadFromFile "https://www.xxxx.xx" "/var/www/xxxx.xx/"; location / { index index.html index.php; ## Allow a static html file to be shown first try_files $uri $uri/ $uri.php?$args; } # nocache by default set $bypass_cache 1; if ($request_uri = /) { set $bypass_cache 0; } # Don't cache POST requests if ($request_method != GET) { set $bypass_cache 1; } location ~ .php$ { ## Execute PHP scripts if (!-e $request_filename) { rewrite / /index.php last; } fastcgi_pass phpfpm:9000; fastcgi_keep_conn on; proxy_intercept_errors on; fastcgi_intercept_errors on; fastcgi_buffer_size 128k; fastcgi_buffers 4 256k; fastcgi_busy_buffers_size 256k; fastcgi_read_timeout 120; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; include /etc/nginx/conf.d/fastcgi_params; fastcgi_cache xxxx; fastcgi_cache_valid 200 302 5m; fastcgi_cache_valid 301 30d; fastcgi_cache_lock on; fastcgi_cache_revalidate on; fastcgi_ignore_headers Cache-Control Expires Set-Cookie; fastcgi_cache_use_stale error timeout invalid_header http_500; fastcgi_cache_valid 5m; fastcgi_cache_bypass $bypass_cache; fastcgi_no_cache $bypass_cache; add_header X-Cache $upstream_cache_status; add_header X-Frame-Options SAMEORIGIN; add_header X-Content-Type-Options nosniff; add_header X-XSS-Protection "1; mode=block"; add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;"; } ## static content is treated different location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|eot|woff2)$ { access_log off; root /var/www/xxxx.xx; expires 30d; add_header Pragma public; add_header Cache-Control "public"; add_header X-Cache $upstream_cache_status; add_header X-Frame-Options SAMEORIGIN; add_header X-Content-Type-Options nosniff; add_header X-XSS-Protection "1; mode=block"; add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;"; } ## All other errors get the generic error page error_page 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 500 501 502 503 504 505 /error_page.html; location /error_page.html { internal; } } server { listen 80 default_server; return 301 https://xxxx/$request_uri; } server { listen 443 ssl; server_name xxxx.xx; return 301 https://xxxx/$request_uri; }
编辑 – 这是如何解决的
我的自定义图像是根本原因。 从dockerhub hub.docker.com/_/nginx使用“原始”nginx,事情就会起作用。
为了提高在评论中讨论的内容的可见性,我发布了一个答案。
这个问题通过使用dockerhub官方docker NGINX版本解决了。
根据Vincent Serpoul最后更新:
“我的自定义图像是根本原因,使用dockerhub hub.docker.com/_/nginx的”原始“nginx,事情就会起作用。