10

if I visit my nginx site with https it is working, but with http it is downloading a file called "download" (no extension whatsoever), 57 bytes and opening it with notepad etc just shows gibberish stuff.

Here's my vhost config:

server {
    server_name www.domain.com domain.com;
    listen 80;

    return 301 https://domain.com$request_uri;
}

server {
    server_name www.domain.com
    listen 443 ssl;

    /* SSL Stuff */

    return 301 https://domain.com$request_uri;
}


server {
    server_name domain.com;
    index index.php index.html index.htm;
    listen 443 ssl;
    root /usr/share/nginx/domain.com;

    /* SSL Stuff */

    location / {
            try_files $uri $uri/ /index.php?$args;
    }


location ~ \.php$ {
            try_files $uri =404;
            fastcgi_pass unix:/run/php/php7.0-fpm.sock;
            fastcgi_param SCRIPT_FILENAME            $document_root$fastcgi_script_name;
            include fastcgi_params;
}

    location ~ /\. {
            deny  all;
    }

}

curl-v:

curl -v http:/domain.com * 
Rebuilt URL to: http://domain.com/ * 
Hostname was NOT found in DNS cache * 
Trying 175.*.*.*... * 
Connected to domain.com (175.*:*:*) port 80 (#0)
 > GET / HTTP/1.1 > User-Agent: curl/7.38.0 
> Host: domain.com > Accept: */* 
> * Connection #0 to host domain.com left intact 
▒▒
  • This config is OK. Check if you restated nginx, configured firewall, or something else – Alexey Ten May 28 '16 at 18:19
  • Also, check with curl -v http://domain.com – Alexey Ten May 28 '16 at 18:19
  • Thanks for you reply. I restarted several times (I tried changing parts of configs, but nothing helped), my firewall is also okay. When checking with curl I get a weird response: ▒▒ just this - doesn't show the source code like it does with https. – rzmpl May 28 '16 at 18:23
  • phpfpm should be up and running and socket should exist in /run/php/php7.0-fpm.sock. – Farhan May 28 '16 at 18:37
  • It does. PHP works - I don't think it is a PHP issue. Everything over HTTPS works, no matter if it is php or not. But if I type http:// or just the domain (in which case it should redirect to https) it just downloads a 57 byte small file called "download" - Nginx error.log doesn't show anything either. – rzmpl May 28 '16 at 18:42
11

I found out what caused the problem: I was using listen 80 http2; in my vhost config which apparently doesn't work. After I removed http2 from said line it is now working normally again!

  • This would have been easy for people to spot, if it had been in your question. You should not omit anything important next time you ask a question. – Michael Hampton May 29 '16 at 19:50
  • I didn't omit anything. How should I been able to know it beforehand? Wouldn't have needed to ask if I knew. But whatever, I sorted it out and that's what matters. – rzmpl May 29 '16 at 22:07
  • 3
    You omitted whatever part of your configuration contained listen 80 http2; which you say was the problem. That made this impossible for anyone else to figure out. – Michael Hampton May 29 '16 at 22:29
  • 1
    So glad you posted this question and followed with your solution! I just encountered this and had no idea what was causing the seemingly random file download. Removing http2 from the one non-SSL site on the server worked! – Graham Swan Jan 2 '17 at 22:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.