I performed the installation of magento2.2.6 with varnish and redis
I am in trouble when I try to access the site through the domain (emporiobit.com.br) Error 503 error occurs Backend fetch failed
When you access the site by https://www.emporiobit.com.br or https://emporiobit.com.br everything works correctly without error.

Follow the doors:
Varnish - 80
Nginx - 81
Ngnix - 443

Before I simply typed the domain and opened the site in https, now it's not happening anymore.

Follow configuration of my nginx

3 Answers 3


your config is absolutely wrong. change nginx top server block to listen on 8080, then varnish listen on 8081.

add another nginx block with port 80, with return to https://

change magento all base urls to https://

in varnish configuration set backend port 8080

updated config will be like this:

upstream fastcgi_backend {
     server  unix:/run/php/php7.1-fpm.sock;

server {
    listen 80;
    server_name emporiobit.com.br www.emporiobit.com.br;
    return 301 https://www.emporiobit.com.br;

server {
    listen 8080;
    server_name emporiobit.com.br www.emporiobit.com.br;
        set $MAGE_ROOT /var/www/html/magento2;
        include /var/www/html/magento2/nginx.conf.sample;

server {
    listen 443 ssl http2;
        server_name emporiobit.com.br www.emporiobit.com.br;

        ## Rewrite hardcoded http links
        sub_filter 'http://'  'https://';
        sub_filter_once off;

        ssl_certificate /etc/certificate/emporiobit.com.br/emporiobit.com.br.crt;
        ssl_certificate_key /etc/certificate/emporiobit.com.br/emporiobit.com.br.key;

       ssl_protocols             TLSv1.2 TLSv1.3;
       ssl_ciphers               'AES128+EECDH:AES128+EDH:!aNULL';
       ssl_session_cache    shared:SSL:10m;
       ssl_session_timeout 24h;
       keepalive_timeout 300s;

    location / {
        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;

https calls bypass varnish completely as you redirect 443 to 81 which are both inside Nginx

http calls do go to varnish and bypass Nginx, but varnish is not setup correctly

Your https headers do not show any varnish cache info i.e. i know you block the varnish header, but you should get some headers from Magento


thanks for the help.
I saw in several places using VARNISH listening on port 80, which one should I use?
In the case the redirect https did in the own configuration of the magento
web/unsecure/base_url - https://www.emporiobit.com.br/
web/secure/base_url - https://www.emporiobit.com.br/

Result pagespeed

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.