Varnish on PHPbb 3.1.x board running into cookie problems

Get help with installation and running phpBB 3.1.x here. Please do not post bug reports, feature requests, or extension related questions here.
Get Involved
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTE: phpBB 3.1.x is at its End of Life stage and support will NOT be provided after July 1st, 2018.
Locked
Erpenator
Registered User
Posts: 17
Joined: Tue Nov 03, 2009 6:45 pm

Varnish on PHPbb 3.1.x board running into cookie problems

Post by Erpenator » Mon Mar 21, 2016 4:54 pm

Dear all,

I am trying to setup Varnish for my website + phpbb 3.1.6 board on a self hosted server. The board is highly customized with our own developed plugins and integrated into the website. This is one of the reasons we need Varnish to speed up the site for guests. Without Varnish the site is working perfectly, but we just want to make it faster.

In our Varnish configuration we we stripped the following cookies:
* PHPSESSID
* phpbb3_f338x_u
* phpbb3_f338x_k
* phpbb3_f338x_sid
This to be able to create a caching object and to strip all cookies when people visit the website as a guest. With this config the Varnish setup works okay for guests and is very fast!

We do not cache posts ($_POSTS) or any request to ucp.php. For posts and for ucp.php all request cookies may exists. Everything seems to work correctly and when we fill out our username and password we can see we are logged in correctly. The next request or click to a other page will log us out again because the cookies above are being stripped (just as the session id). This is why we created the cacheable object and we want to use it again after people login. This also works but only for one cookie.
This is by design by Varnish as you can read here: https://www.varnish-cache.org/trac/ticket/1058

We also added an extra cookie phpbb3_f338x_caching to let Varnish now that if that cookie exists it should not cache the results anymore. But because we can only set one set-cookie-header it means we can not restore all cookies. When we allow all cookies (set-cookies) to be set we hardly see any speed improvements and Varnish becomes useless.

I found a few topics where Varnish is being used with PHP BB and I can see in the headers phpbb.com is also still using Varnish. So to me it should be possible to use.

The question we have right now is what would be the "right" or normal Varnish setup for PHPBB 3.1.x?

User avatar
Mick
Support Team Member
Support Team Member
Posts: 21735
Joined: Fri Aug 29, 2008 9:49 am
Location: Cardiff

Re: Varnish on PHPbb 3.1.x board running into cookie problems

Post by Mick » Tue Mar 22, 2016 4:06 pm

Why do you think you need varnish and why are you messing with phpBB cookie settings? Please fill out the Support Request Template and post it back here to enable us to assist you better. Please note server set up is beyond the scope of support on this site.
"The more connected we get the more alone we become" - Kyle Broflovski

Erpenator
Registered User
Posts: 17
Joined: Tue Nov 03, 2009 6:45 pm

Re: Varnish on PHPbb 3.1.x board running into cookie problems

Post by Erpenator » Tue Mar 22, 2016 4:15 pm

Mick wrote:Why do you think you need varnish and why are you messing with phpBB cookie settings?
As you might know the purpose of Varnish is to speed the site up, the faster the website, the quicker a page is served and the faster pages are crawled by search engines. Which might result in more traffic. Currently the forum is slowing down the crawling of bots and serving the pages to visitors (in terms of miliseconds). This is due to some of the very dynamic plugins (which already use some form of caching).
Mick wrote:Please fill out the Support Request Template and post it back here to enable us to assist you better.
I had a look at the support template and I tried to include all the items that where needed. But here it is. Hope you can help.

Support Request Template
What version of phpBB are you using? phpBB 3.1.6
What is your board's URL? No answer given
Who do you host your board with? Self hosting
How did you install your board? I used the download package from phpBB.com
What is the most recent action performed on your board? Fresh Install
Is registration required to reproduce this issue? No
Do you have any MODs installed? No
Do you have any extensions installed? Yes
What extensions do you have installed? Self build extensions
What styles do you currently have installed? prosilver
What language(s) is your board currently using? NL
Which database type/version are you using? MySQL 5
What is your level of experience? Experienced with PHP and phpBB
What actions did you take (updating your board; installing a MOD, style or extension; etc.) prior to this problem becoming noticeable? No answer given
Please describe your problem. No answer given
Generated by SRT Generator

User avatar
Ramon Fincken
Registered User
Posts: 4835
Joined: Thu Oct 14, 2004 1:04 am
Location: NL, The Netherlands Amsterdam area @GMT +1
Contact:

Re: Varnish on PHPbb 3.1.x board running into cookie problems

Post by Ramon Fincken » Mon Nov 28, 2016 11:12 am

any luck on this one ?
Dutch quality fully managed WordPress hosting - ManagedWPHosting.nl

Before changing a file, some code or installing a MOD >> Make a backup first!

Do you like my mods? paypal me $1 :) forumsoftware[AT}creativepulses[DOT}nl [/size]
PhpBBantispam.com || Instant find your mod here

Erpenator
Registered User
Posts: 17
Joined: Tue Nov 03, 2009 6:45 pm

Re: Varnish on PHPbb 3.1.x board running into cookie problems

Post by Erpenator » Mon Nov 28, 2016 11:18 am

Unfortunately not. We had to give up because we couldn't get it fixed. I hope someone is still able to help us out.

User avatar
Mick
Support Team Member
Support Team Member
Posts: 21735
Joined: Fri Aug 29, 2008 9:49 am
Location: Cardiff

Re: Varnish on PHPbb 3.1.x board running into cookie problems

Post by Mick » Mon Nov 28, 2016 11:31 am

Erpenator wrote:I had a look at the support template and I tried to include all the items that where needed.
What is your board's URL? No answer given
This is important so we can see the issue. Also, we wouldn't know how varnish works so you may be better off asking on a site that deals with that.
"The more connected we get the more alone we become" - Kyle Broflovski

Erpenator
Registered User
Posts: 17
Joined: Tue Nov 03, 2009 6:45 pm

Re: Varnish on PHPbb 3.1.x board running into cookie problems

Post by Erpenator » Mon Nov 28, 2016 11:40 am

The test setup with Varnish is not accessible online without passwords and ip restrictions and we haven't implemented it on the live board so giving the url will not give you any extra information unfortunately.

phpbb.com is using Varnish for this board so someone who does the implantation for this site must know how to set it up or tell if it is impossible or not.

User avatar
Mick
Support Team Member
Support Team Member
Posts: 21735
Joined: Fri Aug 29, 2008 9:49 am
Location: Cardiff

Re: Varnish on PHPbb 3.1.x board running into cookie problems

Post by Mick » Mon Nov 28, 2016 11:48 am

But the point is server setup is beyond the scope of this forum and you would be better off asking on a support site for the product you want to use.
"The more connected we get the more alone we become" - Kyle Broflovski

User avatar
Ramon Fincken
Registered User
Posts: 4835
Joined: Thu Oct 14, 2004 1:04 am
Location: NL, The Netherlands Amsterdam area @GMT +1
Contact:

Re: Varnish on PHPbb 3.1.x board running into cookie problems

Post by Ramon Fincken » Mon Nov 28, 2016 11:49 am

I am using varnish as well , but only enabled it for static files
/assets
/styles
/images
etc..
excluding any /adm paths

unfortunately whitelisting allow cookie set did not work here :(
Dutch quality fully managed WordPress hosting - ManagedWPHosting.nl

Before changing a file, some code or installing a MOD >> Make a backup first!

Do you like my mods? paypal me $1 :) forumsoftware[AT}creativepulses[DOT}nl [/size]
PhpBBantispam.com || Instant find your mod here

Erpenator
Registered User
Posts: 17
Joined: Tue Nov 03, 2009 6:45 pm

Re: Varnish on PHPbb 3.1.x board running into cookie problems

Post by Erpenator » Mon Nov 28, 2016 12:09 pm

Server setup of Varnish is not the problem and I am not asking support for that, because there is only one way to set Varnish up server side (in regards to the cookie problem) and that is what we have done. So the other option left is that something must be different on phpbb.com in the software to make it work.

Therefore the question is what changes did phpbb.com made to make Varnish work with the forum software?

User avatar
Lumpy Burgertushie
Registered User
Posts: 66929
Joined: Mon May 02, 2005 3:11 am
Contact:

Re: Varnish on PHPbb 3.1.x board running into cookie problems

Post by Lumpy Burgertushie » Mon Nov 28, 2016 3:04 pm

a wild guess here. phpbb.com must not be using varnish to mess with the cookies at all. I find it hard to believe that all of the manipulations you describe above with the cookies could do anything but add time to the download of the pages.

phpbb depends on the cookies in order to work properly.

personally, I think that worrying about miliseconds of load time is a bit over the top.


good luck,
robert
I'm baaaaaccckkkk. still doing work on donation basis. PM your needs.

Premium phpBB 3.2 Styles by PlanetStyles.net

If a tree falls in the forest and nobody is there, does it make a sound?

User avatar
Noxwizard
Support Team Leader
Support Team Leader
Posts: 10348
Joined: Mon Jun 27, 2005 8:41 pm
Location: Texas, USA
Name: Patrick Webster
Contact:

Re: Varnish on PHPbb 3.1.x board running into cookie problems

Post by Noxwizard » Tue Nov 29, 2016 2:40 am

It's pretty much what's been speculated in this topic. We only process GET and HEAD requests with Varnish, we strip cookies from certain asset requests (images and the like), if the request isn't for an asset and it has cookies, we just return a pass. You can look at the response headers in your browser to see what's returning a hit or miss to see what we cache on.
[Support Template] - [Read Before Posting] - [phpBB Knowledge Base]
Do not contact me for private support, please share the question in our forums.

User avatar
Ramon Fincken
Registered User
Posts: 4835
Joined: Thu Oct 14, 2004 1:04 am
Location: NL, The Netherlands Amsterdam area @GMT +1
Contact:

Re: Varnish on PHPbb 3.1.x board running into cookie problems

Post by Ramon Fincken » Tue Nov 29, 2016 9:27 am

roger that, thats what I ended up with too.

Yet .. if we are able to cache HTML for guests too that would be great (and save a lot of webserver load)
Dutch quality fully managed WordPress hosting - ManagedWPHosting.nl

Before changing a file, some code or installing a MOD >> Make a backup first!

Do you like my mods? paypal me $1 :) forumsoftware[AT}creativepulses[DOT}nl [/size]
PhpBBantispam.com || Instant find your mod here

whocarez
Registered User
Posts: 144
Joined: Sat Apr 18, 2009 9:19 pm

Re: Varnish on PHPbb 3.1.x board running into cookie problems

Post by whocarez » Fri Mar 10, 2017 2:40 pm

Hi, for short time caching of guest requests, you can try the following in sub vcl_backend_response

Code: Select all

      if (beresp.http.Set-Cookie ~ "phpbb3_.+_u=1;")
    {
	set beresp.uncacheable = false;
	set beresp.ttl = 30s;
	unset beresp.http.Cache-Control;
        unset beresp.http.Set-Cookie;
	unset beresp.http.X-No-Cache;
	set beresp.http.Guest_Cache = {"Yes"};
    }
ttl would be for thirty seconds. With set beresp.http.Guest_Cache = {"Yes"}; you can check whether your condition works or not.
You only need to strip the cookies in sub vcl_recv for static files:

Code: Select all

  if (req.url ~ "^[^?]*\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|ico|jpeg|jpg|js|less|mka|mkv|mov|mp3|mp4|mpeg|mpg|odt|otf|ogg|ogm|opus|pdf|png|ppt|pptx|rar|rtf|svg|svgz|swf|tar|tbz|tgz|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz|zip)(\?.*)?$") {
    unset req.http.Cookie;
    return (hash);
}

Locked

Return to “[3.1.x] Support Forum”