CSS, JS and image files nginx pagespeed mod return not found 404

713 views
Skip to first unread message

Вардан Карапетян

unread,
Jun 19, 2020, 12:15:54 PM6/19/20
to ngx-pagespeed-discuss
I installed the pagespeed module for nginx and after accessing the page, I have all css, js and images, the browser produces 404 not found.
pagespeed FileCachePath /var/cache/nginx/ngx_pagespeed;
pagespeed
RewriteLevel PassThrough;
pagespeed
EnableCachePurge on;
pagespeed
PurgeMethod PURGE;
pagespeed
EnableFilters collapse_whitespace,remove_comments,inline_css,inline_javascript,rewrite_css,rewrite_javascript;

location
~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" {
  add_header
"" "";
}
location
~ "^/pagespeed_static/" { }
location
~ "^/ngx_pagespeed_beacon$" { }

Server my domain:
server {
    server_name example
.ru www.example.ru;
   
#ssl on;
    ssl_certificate
"/var/www/httpd-cert/example/example.ru.crtca";
    ssl_certificate_key
"/var/www/httpd-cert/example/example.ru.key";
    ssl_ciphers EECDH
:+AES256:-3DES:RSA+AES:!NULL:!RC4;
    ssl_prefer_server_ciphers on
;
    ssl_protocols
TLSv1 TLSv1.1 TLSv1.2;
    ssl_dhparam
/etc/ssl/certs/dhparam4096.pem;
    charset UTF
-8;
    index index
.php;
    disable_symlinks if_not_owner
from=$root_path;
    include
/etc/nginx/vhosts-includes/*.conf;
    include /etc/nginx/vhosts-resources/example.ru/*.conf;
    access_log off;
    error_log /dev/null crit;
    ssi on;
    set $root_path /var/www/example/data/www/example.ru;
    root $root_path;
    listen [2a00:f940:2:1:2::18af]:443 ssl;
    listen 37.140.195.150:443 ssl;
    include /etc/nginx/conf.d/pagespeed.inc;
    pagespeed MapOriginDomain "http://localhost" "https://example.ru";
    pagespeed LoadFromFile "https://example.ru" "/var/www/example/data/www/example.ru/";
    #pagespeed Disallow "*.pagespeed.*";
    pagespeed SslCertDirectory /etc/ssl/certs;
    pagespeed SslCertFile /etc/ssl/certs/dhparam4096.pem;
    gzip on;
    gzip_comp_level 6;
    gzip_disable "msie6";
    gzip_min_length    256;
    gzip_proxied       any;
    gzip_vary          on;
    gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript application/rss+xml application/x-font-ttf application/x-font-woff application/x-font-woff2 font/opentype;
    location ~* (\.tpl|.twig|\.ini|\.log|(?<!robots)\.txt) {
        deny all;
    }

    location ~* \/image.+(\.php) {
        deny all;
    }

    location ~* \.(jpg|jpeg|gif|png|webp|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf|woff|woff2|ttf|eof)$ {
        add_header "Access-Control-Allow-Origin" "*";
        add_header Cache-Control "public, max-age=31536000";
        access_log off;
        expires 31536000;
        access_log  off;
    }

    location = /sitemap.xml {
        rewrite ^(.*)$ /index.php?route=extension/feed/google_sitemap last;
    }

    location = /googlebase.xml {
        rewrite ^(.*)$ /index.php?route=extension/feed/google_base last;
    }

    location = /webmaster.rss {
        rewrite ^(.*)$ /index.php?route=extension/payment/yandex_money/market last;
    }

    location /system {
        rewrite ^/system/storage/(.*) /not_found last;
    }

    location = /favicon.ico {
        log_not_found off;
        access_log off;
    }

    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }

    location /xadmin123987 {
        index index.php;
    }

    location / {
        try_files $uri $uri/ @opencart;
    }

    location @opencart {
        rewrite ^/(.+)$ /index.php?_route_=$1 last;
    }

    error_page 404 /not_found;
    location ~ [^/]\.php(/|$) {
        fastcgi_index index.php;
        fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f webm...@example.ru";
        fastcgi_pass unix:/var/www/php-fpm/example.sock;
        fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
        try_files $uri =404;
        include fastcgi_params;
    }
}

And Nginx conf:

TCq2E.jpg

user  apache;
worker_processes  
2;

error_log  
/var/log/nginx/error.log warn;
pid        
/var/run/nginx.pid;
load_module
"modules/ngx_pagespeed.so";

events
{
    worker_connections  
1024;
   
use epoll;
    multi_accept on
;
}


http
{
    include      
/etc/nginx/mime.types;
    default_type  application
/octet-stream;
    server_tokens off
;

    log_format  main  
'$remote_addr - $remote_user [$time_local] "$request" '
                     
'$status $body_bytes_sent "$http_referer" '
                     
'"$http_user_agent" "$http_x_forwarded_for"';

    access_log  
/var/log/nginx/access.log  main;

    sendfile        on
;
    tcp_nodelay on
;
    tcp_nopush on
;

    keepalive_timeout  
65;

   
#gzip  on;

    include
/etc/nginx/conf.d/*.conf;
    include /etc/nginx/vhosts/*/
*.conf;
server
{
        server_name localhost
;
 disable_symlinks if_not_owner
;
    listen
80;
    listen
[::]:80;
    include
/etc/nginx/vhosts-includes/*.conf;
    location @fallback {
        error_log /dev/null crit;
        proxy_pass http://127.0.0.1:8080;
        proxy_redirect http://127.0.0.1:8080 /;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        access_log off ;
    }
    }
    client_max_body_size 128m;
}

I would be grateful for any help Nginx version: 1.16.1 Pagespeed version: 1.13.35.2-0 Server Nginx + PHP-FPM

111.jpg

Longinos

unread,
Jun 19, 2020, 1:37:03 PM6/19/20
to ngx-pagespeed-discuss


See the Github issue

Вардан Карапетян

unread,
Jun 19, 2020, 1:48:24 PM6/19/20
to ngx-pagespeed-discuss
looked at Github, nothing helped me

Longinos

unread,
Jun 19, 2020, 2:06:08 PM6/19/20
to ngx-pagespeed-discuss
I have posted here

Вардан Карапетян

unread,
Jun 19, 2020, 2:15:56 PM6/19/20
to ngx-pagespeed-discuss
Yes, i. Thans very

пятница, 19 июня 2020 г., 21:06:08 UTC+3 пользователь Longinos написал:
Reply all
Reply to author
Forward
0 new messages