cancel
Showing results for 
Search instead for 
Did you mean: 

Nginx directives - admin won't load and home page is missing css/js

Nginx directives - admin won't load and home page is missing css/js

If I keep the following nginx directives enabled, then after install the admin won't load and my home page will be missing css and js...

 

# enable gzip compression
gzip on;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
gzip_http_version 1.1;
gzip_vary on;
gzip_comp_level 4;
gzip_proxied any;
gzip_types text/plain text/xml text/html text/css application/json application/x-javascript application/xml application/xml+rss text/javascript application/javascript text/x-js application/x-font-ttf application/font-woff2 image/x-icon image/svg+xml;
gzip_buffers 16 8k;

# Allow embedded fonts from a third-party URL (CDN) & cache-control headers
location ~* \.(eot|ttf|woff|woff2)$ {
	add_header Access-Control-Allow-Origin *;
	add_header Cache-Control "public, max-age=2628000";
}

#cache-control headers
location ~* \.(gif|jpeg|jpg|png|svg|ico)$ {
	add_header Cache-Control "public, max-age=2628000";
}
location ~* \.(css|js)$ {
	add_header Cache-Control "public, max-age=604800";
}

# Security
# don't send the nginx version number in error pages and Server header
server_tokens off;

# config to enable HSTS(HTTP Strict Transport Security)
add_header Strict-Transport-Security "max-age=31536000; includeSubdomains; preload";

# config to don't allow the browser to render the page inside an frame or iframe
add_header X-Frame-Options "SAMEORIGIN" always;

# This header enables the Cross-site scripting (XSS) filter built into most recent web browsers.
add_header X-Xss-Protection "1; mode=block" always;

# when serving user-supplied content, include a X-Content-Type-Options: nosniff header along with the Content-Type: header,
# to disable content-type sniffing on some browsers.
add_header X-Content-Type-Options "nosniff" always;

However, if I do a clean install with all directives removed beforehand, then everything functions fine.

 

What is the problem? I want to keep the directives as is...

2 REPLIES 2

Re: Nginx directives - admin won't load and home page is missing css/js

Please redeploy your static content for correct locale (in admin) and then check the user permissions/roles for your magento files.

Did you find it helpful? Please give "Kudos" or "Accept as Solution".
Meet 70+ extensions and templates for M1 & M2 in one place


Re: Nginx directives - admin won't load and home page is missing css/js

Everything works if I disable those directives... Only when they're enabled do I have problems. Is there something wrong with these directives that you noticed for nginx?