[ASK] Config Varnish For Nginx on Debian Jessie?


Status
Not open for further replies.

damblue

Poster 1.0
Siang Tuan Tuan,
saya dah instal varnish dan sudah running,
nah pas saya oprek confignya varnish dan ganti port di nano /etc/nginx/sites-available/wp
kgak jlan varnishnya dan domainnya ga jalan :(
berikut cara instal dan confignya, mungkin ada yg salah mohon dibenerin ya :)
apt-get install apt-transport-https
curl https://repo.varnish-cache.org/GPG-key.txt | apt-key add -
echo "deb https://repo.varnish-cache.org/debian/ jessie varnish-4.1" >> /etc/apt/sources.list.d/varnish-cache.list
apt-get update
apt-get install varnish

nano /etc/default/varnish
DAEMON_OPTS="-a :80 \
-T localhost:6082 \
-f /etc/varnish/default.vcl \
-S /etc/varnish/secret \
-s malloc,256m"
nano /etc/varnish/default.vcl
backend default {
.host = "IP Server";
.port = "82";
}

sub vcl_recv {
if (req.url ~ "\.(png|gif|jpg|swf|css|js)$") {
return(lookup);
}
}

# strip the cookie before the image is inserted into cache.

sub vcl_fetch {
if (req.url ~ "\.(png|gif|jpg|swf|css|js)$") {
unset beresp.http.set-cookie;
}
}

nano /etc/nginx/sites-available/wp
server {
listen 127.0.0.1:82;

server_name www.domain.com domain.com;
port_in_redirect off;

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

root /var/www/domain.com/;
index index.php;

location / {
try_files $uri $uri/ /index.php?$args;
}

# Cache static files for as long as possible
location ~*.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf|cur)$ {
expires max;
log_not_found off;
access_log off;
}

# Deny public access to wp-config.php
location ~* wp-config.php {
deny all;
}

location ~ \.php$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}

masalahnya varnish ga jalan dan pastinya domain.com juga ga jalan :(
SS
2016_09_13_132014.jpg

please solusinya.

Thanks.
 

damblue

Poster 1.0
menurut saya jika pakai nginx tidak usah pakai varnish
bisa jelasin om kenapa tidak harus make varnish klo di nginx?
maksud saya mau instal varnish biar lebih optimal aja :D hehehhe klo emang udah optimal di nginx tanpa varnish saya ga instal, mohon penjelasannya biar saya faham. hehehhe soalnya masih baru saya oprek2 VPS :)
 

idnix

Hosting Guru
Verified Provider
bisa jelasin om kenapa tidak harus make varnish klo di nginx?
maksud saya mau instal varnish biar lebih optimal aja :D hehehhe klo emang udah optimal di nginx tanpa varnish saya ga instal, mohon penjelasannya biar saya faham. hehehhe soalnya masih baru saya oprek2 VPS :)
varnish ga se-sederhana itu. karena backend wordpress jg di caching. ada konfigurasi yg kurang
silahkan cari2 lagi referensinya :)
 

paijo2

Apprentice 1.0
Siang Tuan Tuan,
saya dah instal varnish dan sudah running,
nah pas saya oprek confignya varnish dan ganti port di nano /etc/nginx/sites-available/wp
kgak jlan varnishnya dan domainnya ga jalan :(
berikut cara instal dan confignya, mungkin ada yg salah mohon dibenerin ya :)


nano /etc/default/varnish

nano /etc/varnish/default.vcl


nano /etc/nginx/sites-available/wp


masalahnya varnish ga jalan dan pastinya domain.com juga ga jalan :(
SS
2016_09_13_132014.jpg

please solusinya.

Thanks.

coba pakai https://github.com/mattiasgeniar/varnish-4.0-configuration-templates/ .

saya sudah coba pakai untuk melengkapi existing varnish versi 3.4
 
Status
Not open for further replies.


Top