B
B
Belkin2018-04-22 01:53:25
Nginx
Belkin, 2018-04-22 01:53:25

Why does http download a file, but https loads a site?

If you access the site via http, then a file with the content is downloaded:
А€€€€
Using https, the site opens and works.
site works on ocstore and nginx without apache
nginx settings code

server {
     listen 80 http2;
     listen [::]:80 http2;
     server_name me.fun www.me.fun; ## Your Domain
     root /var/www/html/mefun;
     return 301 https://$server_name$request_uri;
}

server {
    server_name localhost me.fun www.me.fun; ## Your Domain
    root /var/www/html/mefun; ## Web Root Directory
    index index.php index.html index.htm;

    client_max_body_size 64m;

    listen 443 default_server ssl http2;
    listen [::]:443 default_server ssl http2;

    ssl_certificate /etc/ssl/me.fun.crt;      
    ssl_certificate_key /etc/ssl/me.fun.key;
    ssl_protocols       TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers         HIGH:!aNULL:!MD5;

    location /image/data {
        autoindex on;
    }
    location /admin {
        index index.php;
    }
    location / { try_files $uri @opencart; }
    location @opencart { rewrite ^/(.+)$ /index.php?_route_=$1 last; }

    
    # Make sure files with the following extensions do not get loaded by nginx because nginx would display the source code, and these files can contain PASSWORDS!
    location ~* \.(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(\..*|Entries.*|Repository|Root|Tag|Template)$|\.php_ {
        deny all;
    }
    #Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
    location ~ /\. {
          deny all;
          access_log off;
          log_not_found off;
    }
    location ~*  \.(jpg|jpeg|png|gif|css|js|ico)$ {
        expires max;
        log_not_found off;
    }
    location ~ [^/]\.php(/|$) {
    	fastcgi_split_path_info  ^(.+\.php)(/.+)$;
    	fastcgi_index            index.php;
    	fastcgi_pass             unix:/var/run/php/php7.1-fpm.sock; # Ubuntu 17.10
    	include                  fastcgi_params;
    	fastcgi_param   PATH_INFO       $fastcgi_path_info;
    	fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

      #pagespeed
  pagespeed off;
  pagespeed RewriteLevel CoreFilters;
  pagespeed FileCachePath "/var/cache/ngx_pagespeed/";
  # Ensure requests for pagespeed optimized resources go to the pagespeed
  # handler and no extraneous headers get set.
  location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" { add_header "" ""; }
  location ~ "^/ngx_pagespeed_static/" { }
  location ~ "^/ngx_pagespeed_beacon" { }


    

    	location ~*  \.(jpg|jpeg|png|gif|ico|css|js|pdf)$ {
        expires 7d;
}


}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
B
Belkin, 2018-04-23
@Belkin

decision to remove http2 from the first block!

D
Danil Sapegin, 2018-04-22
@ynblpb_spb

server {
     listen 80 http2;
     listen [::]:80 http2;
     server_name me.fun www.me.fun; ## Your Domain
     root /var/www/html/mefun;
     location / {
                rewrite ^/(.*)$ https://$host/$1 permanent;
     }
}

try like this

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question