Curious anyone tried using haproxy to load balance Nginx backends which have 
Nginx Pagespeed ngx_pagespeed module enabled ? And are using CDN pull services ?

Problem is a bit complex, so just linking to the full explanation at 
https://groups.google.com/d/topic/ngx-pagespeed-discuss/-pX4cRlcwas/discussion

Summary of problem is

1. haproxy load balances over 4x VPS servers with Nginx backends for 
mydomain.com and each backend VPS has haproxy set cookie unique to each VPS, 
cookie name = vps1, vps2, vps3, vps4

2. each Nginx backend has sites using CDN pull service so that cdn.mydomain.com 
pulls source from mydomain.com

3. one of the VPS has ngx_pagespeed module installed 
https://github.com/pagespeed/ngx_pagespeed which allows optimisation of site 
elements i.e. minification and combining js/css links and rewriting the js/css 
urls.

4. now i have ngx_pagespeed to also rewrite mydomain.com/css and 
mydomain.com/js based urls to using cdn.mydomain.com/css and cdn.mydomain.js 
urls

5. problem is when a visitor visits mydomain.com and calls rewritten 
cdn.mydomain.com/css file, cdn.mydomain get's it's source file from 
mydomain.com which haproxy load balancer runs on and can give the visitor one 
of the other 3 VPSes with non-ngx_pagespeed rewritten urls = 404 not found. So 
essentially, the mydomain.com page call becomes

mydomain.com/index tagged with vps4 cookie which is ngx_pagespeed nginx backend 
based
cdn.mydomain.com/css/style.pagespeed.css tagged with vps1 cookie which isn't 
ngx_pagespeed based so style.css gets 404 not found error

I think haproxy sees 2 user sessions here, the first being from actual user 
hitting mydomain.com and 2nd user it considers the cdn.mydomain.com calling 
mydomain.com original for the css file so it has a different cookie ?

Not sure if there's anything setting wise in haproxy to solve this ?

---
posted at http://www.serverphorums.com
http://www.serverphorums.com/read.php?10,700728,700728#msg-700728

Reply via email to