cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 2.2.6 NGINX add additional location

SOLVED

Magento 2.2.6 NGINX add additional location

Hello there and greetings,

i'm out to find solution for my problem. I'm installing 2.2.6 CE and using 2 NGINX servers cluster suited with HAProxy above it - one common IP and it looks great and perfomance ok.

I was used nginx.conf.sample which is going inside distro.

Web setup version didn't worked ok, but i've installed it via cmd.

 

Now i'm faced a problem. I'm installing commercial theme (my support at theme dev ended and i won't renew it). By manual i should copy theme files to magento root folder, backup everything and then access theme installation folder with browser like this:

https://abc.com/themesetup

 

The problem is that all magento pages are works ok, but when i'm accessing this address, i'm getting 404 Error.

File permissions are ok, folder owner also ok. So i think i have to add location to nginx.conf.sample for this directory, but i have no idea how to do that - i was trying different version of location, but all the time i'm getting 404. I was checked folder contents - there is index.php and so on.

In nginx logs i can see the follow:

 

[12/Nov/2018:04:39:40 +0300] "GET /setup/themesetup HTTP/2.0" 404 513 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:63.0) Gecko/20100101 Firefox/63.0"
1 ACCEPTED SOLUTION

Accepted Solutions

Re: Magento 2.2.6 NGINX add additional location

I was figured out that issue by myseld, maybe somebody will need such solution.

Just add such block in nginx.conf.sample after #setup section:

 

# PHP entry point for THEME application
location /themesetup {
    root $MAGE_ROOT;
    location ~ ^/themesetup/index.php {

        ### This fixes the problem:
        fastcgi_split_path_info ^(.+?\.php)(/.*)$;
        ################################

        fastcgi_pass   fastcgi_backend;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

    location ~ ^/themesetup/(?!pub/). {
        deny all;
    }

    location ~ ^/themesetup/pub/ {
        add_header X-Frame-Options "SAMEORIGIN";
    }
}                

Also i was looking for fix when you using NGINX and setup won't run via web - it was in issues in old Magento github, but it lost in time, looks like, so you have to change #setup section to get it working:

location /setup {
    root $MAGE_ROOT;
    location ~ ^/setup/index.php {

        ### This fixes the problem:
        fastcgi_split_path_info ^(.+?\.php)(/.*)$;
        ################################

        fastcgi_pass   fastcgi_backend;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
        fastcgi_read_timeout 600s;
        fastcgi_connect_timeout 600s;

    }

    location ~ ^/setup/(?!pub/). {
        deny all;
    }

    location ~ ^/setup/pub/ {
        add_header X-Frame-Options "SAMEORIGIN";
    }
}

After you change it on code part above - restart nginx and be happy.

View solution in original post

1 REPLY 1

Re: Magento 2.2.6 NGINX add additional location

I was figured out that issue by myseld, maybe somebody will need such solution.

Just add such block in nginx.conf.sample after #setup section:

 

# PHP entry point for THEME application
location /themesetup {
    root $MAGE_ROOT;
    location ~ ^/themesetup/index.php {

        ### This fixes the problem:
        fastcgi_split_path_info ^(.+?\.php)(/.*)$;
        ################################

        fastcgi_pass   fastcgi_backend;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

    location ~ ^/themesetup/(?!pub/). {
        deny all;
    }

    location ~ ^/themesetup/pub/ {
        add_header X-Frame-Options "SAMEORIGIN";
    }
}                

Also i was looking for fix when you using NGINX and setup won't run via web - it was in issues in old Magento github, but it lost in time, looks like, so you have to change #setup section to get it working:

location /setup {
    root $MAGE_ROOT;
    location ~ ^/setup/index.php {

        ### This fixes the problem:
        fastcgi_split_path_info ^(.+?\.php)(/.*)$;
        ################################

        fastcgi_pass   fastcgi_backend;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
        fastcgi_read_timeout 600s;
        fastcgi_connect_timeout 600s;

    }

    location ~ ^/setup/(?!pub/). {
        deny all;
    }

    location ~ ^/setup/pub/ {
        add_header X-Frame-Options "SAMEORIGIN";
    }
}

After you change it on code part above - restart nginx and be happy.