-
-
Save jschuur/6aae550e0d0d1d607729 to your computer and use it in GitHub Desktop.
Attempt at getting varnish to work with multiple sites (WordPress and Rails) on a single server.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Configuration file for varnish | |
# | |
# /etc/init.d/varnish expects the variables $DAEMON_OPTS, $NFILES and $MEMLOCK | |
# to be set from this shell script fragment. | |
# | |
# Note: If systemd is installed, this file is obsolete and ignored. You will | |
# need to copy /lib/systemd/system/varnish.service to /etc/systemd/system/ and | |
# edit that file. | |
# Should we start varnishd at boot? Set to "no" to disable. | |
START=yes | |
# Maximum number of open files (for ulimit -n) | |
NFILES=131072 | |
# Maximum locked memory size (for ulimit -l) | |
# Used for locking the shared memory log in memory. If you increase log size, | |
# you need to increase this number as well | |
MEMLOCK=82000 | |
DAEMON_OPTS="-a :80 \ | |
-T localhost:6082 \ | |
-f /etc/varnish/default.vcl \ | |
-S /etc/varnish/secret \ | |
-s malloc,64m" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a basic VCL configuration file for varnish. See the vcl(7) | |
# man page for details on VCL syntax and semantics. | |
# | |
# Default backend definition. Set this to point to your content | |
# server. | |
# | |
backend default { | |
.host = "joostschuur.com"; | |
.port = "8080"; | |
} | |
sub vcl_recv { | |
# Skip Rails sites | |
if (req.http.host ~ "hellorails.joostschuur.com" ) { | |
return (pass); | |
} | |
# Drop any cookies sent to Wordpress. | |
if (!(req.url ~ "wp-(login|admin)")) { | |
unset req.http.cookie; | |
} | |
} | |
# Drop any cookies Wordpress tries to send back to the client. | |
sub vcl_fetch { | |
if (!(req.url ~ "wp-(login|admin)")) { | |
unset beresp.http.set-cookie; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user www-data; | |
worker_processes 1; | |
#error_log logs/error.log; | |
#error_log logs/error.log notice; | |
#error_log logs/error.log info; | |
pid logs/nginx.pid; | |
events { | |
worker_connections 1024; | |
} | |
http { | |
passenger_root /usr/local/rvm/gems/ruby-1.9.3-p392/gems/passenger-3.0.19; | |
passenger_ruby /usr/local/rvm/wrappers/ruby-1.9.3-p392/ruby; | |
include mime.types; | |
default_type application/octet-stream; | |
sendfile on; | |
#tcp_nopush on; | |
#keepalive_timeout 0; | |
keepalive_timeout 65; | |
#gzip on; | |
server_names_hash_bucket_size 64; | |
server { | |
server_name hellorails.joostschuur.com; | |
listen 80; | |
root /www/hellorails.joostschuur.com/public; | |
passenger_enabled on; | |
} | |
server { | |
server_name www.joostschuur.com joostschuur.com; | |
listen 127.0.0.1:8080; | |
root /www/joostschuur.com/htdocs; | |
index index.php index.html index.htm; | |
access_log logs/joostschuur-access.log; | |
error_log logs/joostschuur-error.log; | |
location / { | |
try_files $uri $uri/ /index.php?q=$uri&$args; | |
} | |
error_page 404 /404.html; | |
error_page 500 502 503 504 /50x.html; | |
location = /50x.html { | |
root /opt/nginx/html; | |
} | |
location ~ \.php$ { | |
fastcgi_pass unix:/var/run/php5-fpm.sock; | |
fastcgi_index index.php; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_sc | |
ript_name; | |
include fastcgi_params; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment