cache
SSL backend behind varnish
I try this long time ago , but with no luck.. I wrote this tutorial but still https doesn’t workin. Its open 443 port , but in varnishlog it says “timeout”.
Today I decide to try little trick with rinetd (debian based port forwarding tool) to redirect 443 port to my local ip address of the web server. This is my rinetd.conf :
# # this is the configuration file for rinetd, the internet redirection server # # you may specify global allow and deny rules here # only ip addresses are matched, hostnames cannot be specified here # the wildcards you may use are * and ? # allow * # # forwarding rules come here # # you may specify allow and deny rules after a specific forwarding rule # to apply to only that forwarding rule # # bindadress bindport connectaddress connectport my.web.address.of.varnish.cache.server 443 192.168.*.* 443 # logging information logfile /var/log/rinetd.log # uncomment the following line if you want web-server style logfile format # logcommon
I remove 443 port on /etc/default/varnish , restart rinetd and now my blog works with https and spdy!
I know that varnish now doesn’t cache , but the main purpose is http to works , and now it works! Now I’m behind varnish again! I feel good yeah! My score at pingdom will continue to increase :whistle:
Optimizing WordPress with Nginx, Varnish, APC, W3 Total Cache
Идеята е ясна – оптимизация на уордпрес блога чрез varnish който работи пред nginx-a с една едничка цел – по-бързо отваряне на сайта ни.
Първо инсталираме nginx и php-fpm :
apt-get install nginx php5-fpm
Ето и примерния ни nginx.conf:
user www-data;
worker_processes 12;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
worker_rlimit_nofile 8192;
events {
worker_connections 4096;
# multi_accept on;
}
http {
include /etc/nginx/mime.types;
# include /etc/nginx/proxy.conf;
include /etc/nginx/fastcgi.conf;
access_log /var/log/nginx/access.log;
upload_progress proxied 1m;
#cache
#fastcgi_cache_path /tmp/cache/fastcgi_cache levels=1:2 keys_zone=php:16m inactive=5m max_size=500m;
proxy_cache_path /var/www/cache/ levels=1:2 keys_zone=алабала.нет:10m inactive=30m max_size=2g;
upstream php5-fpm-sock {
server 127.0.0.1:9000 weight=100 max_fails=3 fail_timeout=5;
#server 127.0.0.1:9001 weight=100 max_fails=3 fail_timeout=5;
#server unix:/var/run/php5-fpm.sock;
}
#sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
tcp_nodelay on;
gzip on;
gzip_disable “MSIE [1-6]\.(?!.*SV1)”;
gzip_http_version 1.0;
gzip_comp_level 9;
gzip_proxied any;
gzip_min_length 1100;
gzip_buffers 16 8k;
gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
server_tokens on;
server_name_in_redirect off;
}
След това е нужно да създадем виртуален хост за сайта ни – /etc/nginx/sites-enabled/виртуален-хост.лтд