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

Navigation in catalog view missing when Varnish is activated #3421

Closed
duerstd opened this issue Feb 16, 2016 · 27 comments
Closed

Navigation in catalog view missing when Varnish is activated #3421

duerstd opened this issue Feb 16, 2016 · 27 comments

Comments

@duerstd
Copy link

duerstd commented Feb 16, 2016

Hi there,

We currently installed and activated Varnish on our new Magento 2 solution. After the installation was successfully, we noticed that the navigation on the catalog view (just on the catalog view) is gone.

Our guess is that something in the varnish configuration file (default.vcl) which we exported from our Magento 2 shop is missing (http://devdocs.magento.com/guides/v2.0/config-guide/varnish/config-varnish-magento.html -> see step 7).
This because after the varnish installation on the server (before the activation in the Magento 2 backend) everything worked fine. Then we activated varnish in the Magento 2 backend, the hole navigation was gone. After updating the default.vcl file with the exported one from the Magento 2 backend, the navigation on the static pages came back - but not the navigation on the catalog view.

System information:
CentOS 6 and 7
Apache 2.2.15
Magento 2.0.2

Checkout the screenshots:
static_page_view_navigation_correct
catalog_view_navigation_missing

@erikhansen
Copy link
Contributor

I have also experienced the same issue where the main navigation disappears when Varnish is enabled.

@erikhansen
Copy link
Contributor

@duerstd I created a new issue with steps to reproduce this issue: #3897 Can you close this task since it reports the same issue as my newly created issue?

@mazhalai
Copy link
Contributor

Closing as duplicate

@OmarFaruque
Copy link

I am facing same problem after install new Magento 2.1.1

@Jilco
Copy link

Jilco commented Dec 27, 2016

I removed the TTL attribute from /vendor/magento/module-theme/view/frontend/layout/default.xml and the menu bar was there again! But can that do any harm, if I'm correct the default TTL is enheritated. Or am I wrong?

@mkleim
Copy link

mkleim commented Jan 3, 2017

Hi, thanks a lot for that hint.
Worked really well after reindexing.
I´m happy about that

@ASirik
Copy link

ASirik commented Feb 7, 2017

hey @duerstd did you fix the issue ?

@jpcsguru
Copy link

hi,
having same issue any fix?

@kllee824
Copy link

I got the same issue and fixed it by removed TTL attribute.

Thanks a lot

@likeweb
Copy link

likeweb commented Mar 22, 2018

Information
The TTL attribute can be found under:
vendor/magento/module-theme/view/frontend/layout/default.xml
remove the ttl="3600"

varnish02

After removing the attribute and clearing cache the varnish cache worked fine for me

@avadh88
Copy link

avadh88 commented Mar 30, 2018

Enter Code in theme default.xml

<referenceBlock name="store.menu"> <block class="Magento\Theme\Block\Html\Topmenu" cacheable="false" /> </referenceBlock>

@erikhansen
Copy link
Contributor

Beware of using cacheable="false" in layout XML. Any page that contains a block with cacheable="false" will never be cached in the Full Page Cache. So I would not recommend the solution that @vadh88 just posted.

@avadh88
Copy link

avadh88 commented Apr 2, 2018

@erikhansen If we use full page varnish cache menu disappears. If we remove ttl from vendor file is not a feasible solution. are you know how to remove TTL from block ?

@erikhansen
Copy link
Contributor

@avadh88 Check out this comment as it might be relevant. Specifically, check to see if the view/base/layout/default.xml file in your installation contains this string layout="admin-1column" (it should not contain that string).

@ghost
Copy link

ghost commented Apr 16, 2018

Hi Guys, Is there any other solution rather than remove the TTL attribute from the block? It looks that's not the proper solution:

I'm using:
Varnish (varnish-4.0.5 revision 07eff4c29)
Magento 2.2.3

Thanks

@Jilco
Copy link

Jilco commented Apr 16, 2018 via email

@Jilco
Copy link

Jilco commented Apr 16, 2018 via email

@ghost
Copy link

ghost commented Apr 16, 2018

@Jilco is not an option disregard varnish at this point for me. thanks anyway.

@gcampedelli
Copy link

I think they should reopen this issue. I found another partial solution using varnish which is here in the power point - https://pt.slideshare.net/TonyBrown44/magento-2-and-avoiding-the-rabbit-hole
Even if the solution results in menu displaying in checkout page, it does not solve the problem in home and catalog pages. I found a way to solve that but using Apache2+ Varnish. I now switch to Nginx + Varnish and I found the same problem and just arrived to solve to display menu in some pages. So, it is something in the server configuration which is missing in Magento2 Dev Docs which are a bit confusing once Varnish part is totally redirected to Apache 2 and Optimization suggests to use Nginx.

@ghost
Copy link

ghost commented Apr 20, 2018

@gcampedelli I think is the same solution proposed here in this issue: #3897

Do you have tried that? Is it working for you?

Thanks

@gcampedelli
Copy link

gcampedelli commented Apr 20, 2018

I solved it using the solution described in Varnish but for Magento 2.2.2. I didn't remove TTL from layout. But I managed to do it in Magento 2.2.2. When I switched to Magento 2.2.3 it happened again. Menu only displays in Checkout. I will try the Magento 2.2.3 install again, but I will check if the issue is not coming from .htaccess.

@ghost
Copy link

ghost commented Apr 20, 2018

@gcampedelli yes, I'm on v2.2.3 and "-p feature=+esi_ignore_https" varnish option didn't work for me, I had to perform an override of the Topmenu block on my theme layout xml.

@gcampedelli
Copy link

gcampedelli commented Apr 20, 2018

Well, the solution just worked after changing some Apache 2 settings.
Here is my Apache 2 configuration

<IfModule mod_ssl.c>
<VirtualHost *:443>
RequestHeader set X-Forwarded-Proto "https" 
#RequestHeader set X-Forwarded-Port "443" #ProxyRequests Off 
DocumentRoot /var/www/html/magento2 
ServerName mydomain.com 
ServerAlias www.mydomain.com 
Header always set Strict-Transport-Security "max-age=63072000; includeSubDomains; preload"
<Directory /var/www/html/magento2>
Options Indexes FollowSymLinks
Allowoverride All
Require all granted
Include /etc/letsencrypt/options-ssl-apache.conf
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:80/ retry=1 acquire=3000 timeout=600 Keepalive=On
ProxyPassReverse / http://127.0.0.1:80/
SSLCertificateFile /etc/letsencrypt/live/mydomain/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/mydomain/privkey.pem
</VirtualHost>
</IfModule>

@muckee
Copy link

muckee commented Jun 27, 2018

Hi @gcampedelli . Thanks for the solution! Unfortunately, my settings are much more basic than yours and I can't figure out which parts are important. I am having the same problem when connecting to only http, with SSL de-activated in the magento settings.

Which were the lines that fixed it for you?

Thanks.

@gcampedelli
Copy link

It is hard to help if I don't know your settings. But I had to change varnish and Apache 2 configuration as written above.
This lines - RequestHeader set X-Forwarded-Proto "https"

Include /etc/letsencrypt/options-ssl-apache.conf
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:80/ retry=1 acquire=3000 timeout=600 Keepalive=On
ProxyPassReverse / http://127.0.0.1:80/
SSLCertificateFile /etc/letsencrypt/live/mydomain/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/mydomain/privkey.pem

And same for NGINX in other server which the configuration using varnish is like this

upstream fastcgi_backend {
server unix:/var/run/php/php7.0-fpm.sock;
}
server {
server_name meulindodominio.com.br;
listen 8080;
set $MAGE_ROOT /var/www/html/magento2;
set $MAGE_MODE production; # or developer

access_log /var/log/nginx/dmeulindodominio.com.br.com-access.log;
error_log /var/log/nginx/meulindodominio.com.br-error.log;

include /var/www/html/magento2/nginx.conf.sample;        

}

server {

listen 443 ssl http2;
server_name meulindodominio.com.br;
proxy_headers_hash_bucket_size 128;
proxy_headers_hash_max_size 1024;
ssl_certificate /etc/letsencrypt/live/meulindodominio.com.br/fullchain.pem; # managed by Certbot    
ssl_certificate_key /etc/letsencrypt/live/meulindodominio.com.br/privkey.pem; # managed by Certbot
ssl_protocols              TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers               'AES128+EECDH:AES128+EDH:!aNULL';
#ssl_session_cache    shared:SSL:10m;
#ssl_session_timeout 24h;
#keepalive_timeout 300s;

location / {
    proxy_pass http://127.0.0.1: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-Proto https;
    proxy_set_header      X-Forwarded-Port 443;
    #proxy_hide_header X-Varnish;
    #proxy_hide_header Via;
    proxy_set_header X-Forwarded-Proto $scheme;
    include fastcgi.conf;

}
location /phpmyadmin {
           root /usr/share/;
           index index.php index.html index.htm;
           location ~ ^/phpmyadmin/(.+\.php)$ {
                   try_files $uri =404;
                   root /usr/share/;
                   fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
                   fastcgi_index index.php;
                   fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                   include /etc/nginx/fastcgi_params;
           }
           location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
                   root /usr/share/;
           }
    }
    location /phpMyAdmin {
           rewrite ^/* /phpmyadmin last;
    }

}

@muckee
Copy link

muckee commented Jun 27, 2018

No worries I have just noticed all sorts of problems with the varnish server configuration. Will let you know if the problem persists once I've cleaned it up. Thanks!

@iancassidyweb
Copy link
Contributor

For anyone coming across this issue in the future please ensure you've read Magento's support article.

https://support.magento.com/hc/en-us/articles/360028757791-Top-navigation-panel-does-not-load-on-storefront

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests