SatelliteWP / rocket-nginx

Rocket-Nginx is a Nginx configuration that makes WP-Rocket even faster by serving static pages directly without loading WordPress or PHP.
MIT License
579 stars 129 forks source link

Index page - download file #161

Closed mSys-mislav closed 3 years ago

mSys-mislav commented 3 years ago

Describe the bug A clear and concise description of what the bug is.

I've installed rocket-nginx, included rocket-nginx/default.conf file in the vhost file and after restart nginx, index file (homepage) is getting downloaded. Funny thing is...e.g. /about-us page works. WP admin also works, but homepage, not.

Versions What version of Nginx are you using ? 1.14.2 What version of Rocket-Nginx are you using ? Latest What version of WP Rocket are you using ? 3.8.8 Are you using Nginx as a reverse proxy (with Apache for instance) ? Nginx+php-fpm (no apache)

To Reproduce Steps to reproduce the behaviour:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error It's clients website, I'm not able to provide this info.

Did you activate the debug in Rocket-Nginx ? Please do and include any headers. Activating debug makes no difference, as I'm unable to open the homepage where this issue persist.

Make sure you include ALL Nginx configuration files you are using. Remove any sensitive information before submitting. ` server { listen *:80; listen [::]:80;

    server_name XX ;

    root   /var/www/XX/web/;
            disable_symlinks if_not_owner from=$document_root;

    index index.html index.htm index.php index.cgi index.pl index.xhtml;

    error_log /var/log/ispconfig/httpd/XX/error.log;
    access_log /var/log/ispconfig/httpd/XX/access.log combined;

    location ~ /\. {
                    deny all;
    }

    location ^~ /.well-known/acme-challenge/ {
                    access_log off;
                    log_not_found off;
                    auth_basic off;
                    root /usr/local/ispconfig/interface/acme/;
                    autoindex off;
                    index index.html;
                    try_files $uri $uri/ =404;
    }

    location = /favicon.ico {
        log_not_found off;
        access_log off;
        expires max;
        add_header Cache-Control "public, must-revalidate, proxy-revalidate";
    }

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

    location /stats/ {

        index index.html index.php;
        auth_basic "Members Only";
        auth_basic_user_file /var/www/XX/web/stats/.htpasswd_stats;
        add_header Content-Security-Policy "default-src * 'self' 'unsafe-inline' 'unsafe-eval' data:;";
    }

    location ^~ /awstats-icon {
        alias /usr/share/awstats/icon;
    }

    location ~ \.php$ {
        try_files /14909d7745c7ebd6f03fc9ca34fca2c4.htm @php;
    }

    location / {
    try_files $uri $uri/ /index.php?$args;
    }
    location ~* .(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
            expires max;
            log_not_found off;
            access_log off;
    }
    include rocket-nginx/default.conf;
    location = /xmlrpc.php {
        deny all;
        access_log off;
        log_not_found off;
    }

    location @php {
        try_files $uri =404;
        include /etc/nginx/fastcgi_params;
        fastcgi_pass unix:/var/lib/php7.3-fpm/web34.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_intercept_errors on;
    }

}

nginx.conf

user www-data; worker_processes auto; pid /run/nginx.pid; include /etc/nginx/modules-enabled/*.conf;

events { worker_connections 1024; multi_accept on; }

http {

map $remote_addr $ip_anonym1 { default 0.0.0; "~(?P(\d+).(\d+).(\d+)).\d+" $ip; "~(?P[^:]+:[^:]+):" $ip; }

map $remote_addr $ip_anonym2 { default .0; "~(?P(\d+).(\d+).(\d+)).\d+" .0; "~(?P[^:]+:[^:]+):" ::; }

map $ip_anonym1$ip_anonym2 $ip_anonymized { default 0.0.0.0; "~(?P.*)" $ip; }

log_format anonymized '$ip_anonymized - $remote_user [$time_local] ' '"$request" $status $body_bytes_sent ' '"$http_referer" "$http_user_agent"';

    ##
    # Basic Settings
    ##
    client_max_body_size 64M;
    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 3;
    keepalive_requests 1000;
    types_hash_max_size 2048;
    server_tokens off;
    access_log off;

    server_names_hash_bucket_size 128;
    # server_name_in_redirect off;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    ##
    # SSL Settings
    ##
    ssl_dhparam /etc/nginx/dhparam;
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
    ssl_prefer_server_ciphers off;
    # HSTS (ngx_http_headers_module is required) (63072000 seconds)
    add_header Strict-Transport-Security "max-age=63072000" always;
    # OCSP stapling
    ssl_stapling on;
    ssl_stapling_verify on;

    ##
    # Logging Settings
    ##

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    ##
    # Gzip Settings
    ##

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

    ##
    # Virtual Host Configs
    ##

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;

}

`

Expected behavior A clear and concise description of what you expected to happen.

Website should load normally, without file download.

Additional context Add any other context about the problem here.

Let me know if anything else is needed.

maximejobin commented 3 years ago

Can you include Rocket-Nginx just after the index instruction to see if it makes a difference?

Don't forget to reload the configuration after that before you test.

mSys-mislav commented 3 years ago

We've tried it and it works. What/where is the catch? :)

maximejobin commented 3 years ago

The execution order is important. If the code it too low in your configuration, it is simply not executed.

Enjoy!