Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wordpress configuration #7

Merged
merged 10 commits into from Nov 21, 2012
Merged
1 change: 1 addition & 0 deletions .gitignore
@@ -1,4 +1,5 @@
# Ignore these files
.gitconfig
secret
default.vcl
custom.acl.vcl
Expand Down
34 changes: 21 additions & 13 deletions README.md
@@ -1,19 +1,27 @@
# Varnish Configuration Templates (boilerplate)
## Varnish Configuration Templates (boilerplate)

## Installation
### Installation
You can use the configuration templates found in this repository to quickly get started with a complete Varnish configuration that offers support for most functionality.

## What is it?
### What is it?
A set of configuration samples used for Varnish 3.0. This includes templates for:
- Wordpress
- Drupal (works decently for Drupal 7, depends on your addons obviously)
- Joomla (WIP)
- Fork CMS (works decently enough)
- OpenPhoto
* Wordpress
* Drupal (works decently for Drupal 7, depends on your addons obviously)
* Joomla (WIP)
* Fork CMS (works decently enough)
* OpenPhoto

And various configuration for:
- Server-side URL rewriting
- Clean error pages for debugging
- Virtual Host implementations
- Various header normalizations
- Cookie manipulations
* Server-side URL rewriting
* Clean error pages for debugging
* Virtual Host implementations
* Various header normalizations
* Cookie manipulations

## Contributors
Ordered by date of first contribution.
[Auto-generated](http://github.com/dtrejo/node-authors) on Wed Nov 07 2012 16:57:35 GMT+0100 (CET).

- [Mattias Geniar aka `mattiasgeniar`](https://github.com/mattiasgeniar)
- [Pascal A. aka `pad92`](https://github.com/pad92)
- [Thijs Feryn aka `ThijsFeryn`](https://github.com/ThijsFeryn)
4 changes: 2 additions & 2 deletions conf.d/error-404.vcl
Expand Up @@ -14,7 +14,7 @@ synthetic {"
<meta name="generator" content="vim">
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
<!-- Le styles -->
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.0/css/bootstrap-combined.min.css" rel="stylesheet">
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.1/css/bootstrap-combined.min.css" rel="stylesheet">
<style>
body {
padding-top: 60px; /* 60px to make the container go all the way to the bottom of the topbar */
Expand All @@ -31,7 +31,7 @@ synthetic {"
<h1 class="pagination-centered">Error "} + obj.status + " " + obj.response + {"</h1>
</div>
</div>
<script src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.0/js/bootstrap.min.js"></script>
<script src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.1/js/bootstrap.min.js"></script>
</body>
</html>
"};
4 changes: 2 additions & 2 deletions conf.d/error.vcl
Expand Up @@ -14,7 +14,7 @@ synthetic {"
<meta name="generator" content="vim">
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
<!-- Le styles -->
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.0/css/bootstrap-combined.min.css" rel="stylesheet">
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.1/css/bootstrap-combined.min.css" rel="stylesheet">
<style>
body {
padding-top: 60px; /* 60px to make the container go all the way to the bottom of the topbar */
Expand Down Expand Up @@ -132,7 +132,7 @@ synthetic {"
<footer class="container pagination-centered">
</footer>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.0/js/bootstrap.min.js"></script>
<script src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.1/js/bootstrap.min.js"></script>
</body>
</html>
"};
12 changes: 3 additions & 9 deletions conf.d/fetch/wordpress.vcl
@@ -1,10 +1,4 @@
# The vcl_fetch routine, when the request is fetched from the backend

# For static content related to the theme, strip all backend cookies
if (req.url ~ "\.(html|css|js|png|gif|jp(e?)g)") {
unset beresp.http.cookie;
set beresp.ttl = 1d;
} else {
# A TTL of 30 minutes
set beresp.ttl = 1h;
# Drop any cookies Wordpress tries to send back to the client.
if (!(req.url ~ "wp-(login|admin)")) {
unset beresp.http.set-cookie;
}
34 changes: 2 additions & 32 deletions conf.d/receive/wordpress.vcl
@@ -1,38 +1,8 @@
# A configuration file specific to Wordpress 3.x

# Either the admin pages or the login
if (req.url ~ "/wp-(login|admin)") {
# Don't cache, pass to backend
return (pass);
}

# Remove the wp-settings-1 cookie
set req.http.Cookie = regsuball(req.http.Cookie, "wp-settings-1=[^;]+(; )?", "");

# Remove the wp-settings-time-1 cookie
set req.http.Cookie = regsuball(req.http.Cookie, "wp-settings-time-1=[^;]+(; )?", "");

# Remove the wp test cookie
set req.http.Cookie = regsuball(req.http.Cookie, "wordpress_test_cookie=[^;]+(; )?", "");

# Static content unique to the theme can be cached (so no user uploaded images)
# The reason I don't take the wp-content/uploads is because of cache size on bigger blogs
# that would fill up with all those files getting pushed into cache
if (req.url ~ "wp-content/themes/" && req.url ~ "\.(css|js|png|gif|jp(e)?g)") {
# Drop any cookies sent to Wordpress.
if (!(req.url ~ "wp-(login|admin)")) {
unset req.http.cookie;
}

# Even if no cookies are present, I don't want my "uploads" to be cached due to their potential size
if (req.url ~ "/wp-content/uploads/") {
return (pass);
}

# Check the cookies for wordpress-specific items
if (req.http.Cookie ~ "wordpress_" || req.http.Cookie ~ "comment_") {
# A wordpress specific cookie has been set
return (pass);
}

# Anything else left?
if (!req.http.cookie) {
unset req.http.cookie;
Expand Down
2 changes: 2 additions & 0 deletions production.vcl
Expand Up @@ -247,6 +247,8 @@ sub vcl_error {
} elsif (obj.status <= 200 && obj.status >= 299 ) {
# for other errors (not 5xx, not 4xx and not 2xx)
include "conf.d/error.vcl";
} else {
include "conf.d/error.vcl";
}
return (deliver);
}
Expand Down