Varnish : Varnish not loading CSS and JS.
Akshay Sulakhe
kernelfreak at gmail.com
Tue Oct 8 13:17:37 UTC 2019
Hello friends,
I am running magento 2.2.6 on a nginx server. I have Varnish installed
on another dedicated server. When I use it via proxy-pass and contact
varnish server first, I am able to load the magento website, but CSS and
JS are not loading due to strict mime-type issue.
Error log :
|pub/static/version123456/frontend/company/default/de_DE/css/styles-1.min.css
was blocked due to MIME type ("text/html")mismatch
(X-Content-Type-Options:nosniff) |
We don't have no-sniff added in our Nginx configuration.
Varnish config :
default.vcl
|backend server1c {.host ="IP1";.port ="80";.probe ={.url
="/balancer.html";.timeout =500s;.interval =5s;.window =5;.threshold
=3;}}backend server1b {.host ="IP2";.port ="80";.probe ={.url
="/balancer.html";.timeout =500s;.interval =5s;.window =5;.threshold
=3;}}backend server1a {.host ="IP3";.port ="80";.probe ={.url
="/pub/balancer.html";.timeout =500s;.interval =5s;.window =5;.threshold
=3;}}subvcl_recv {# Happens before we check if we have this in cache
already.## Typically you clean up the request here, removing cookies you
don't need,# rewriting the request, etc.if(req.url
=="/lazyload/prices/load/"){return(pass);}if(req.url
=="/roobeo_config/store/changemode/mode/0"){return(pass);}if(req.url
=="/roobeo_config/store/changemode/mode/1"){return(pass);}if(req.url
=="/rest/default/V1/carts/mine/estimate-shipping-methods"){return(pass);}if(req.url
=="/lazywishlist/"){return(pass);}if(req.url
=="/index.php/rest/V1/"){return(pass);}if(req.url
=="/customer/account/createpassword/"){return(pass);}if(req.url
=="/customer/account/resetpasswordpost/"){return(pass);}if(req.url
=="/roobeo_shipping/zipcode/validate/"){return(pass);}if(req.url
=="/roobeo_shipping/zipcode/save/"){return(pass);}if(req.url
=="/roobeo_shipping"){return(pass);}}subvcl_init {newbar
=directors.round_robin();bar.add_backend(server1a);bar.add_backend(server1b);bar.add_backend(server1c);}|
Nginx config :
|location /{proxy_pass http://VARNISH_IP:80;proxy_set_header
Host$http_host;proxy_set_header
X-Forwarded-Host$http_host;proxy_set_header X-Real-IP
$remote_addr;proxy_set_header
X-Forwarded-For$proxy_add_x_forwarded_for;proxy_set_header
Ssl-Offloaded"1";proxy_set_header
X-Forwarded-Protohttps;proxy_set_header
X-Forwarded-Port443;#proxy_hide_header X-Varnish;#proxy_hide_header
Via;proxy_set_header X-Forwarded-Proto$scheme;try_files $uri
$uri//index.php$is_args$args;} Any ideas. Thank you. :-) |
||
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20191008/b2cd85c5/attachment-0001.html>
More information about the varnish-misc
mailing list