Vesta Control Panel - Forum

Community Forum

Skip to content

Advanced search
  • Quick links
    • Main site
    • Github repo
    • Google Search
  • FAQ
  • Login
  • Register
  • Board index Main Section Web Server
  • Search

HTTP downloading php, HTTPS serving php. [SELF-FIXED]

Questions regarding the Web Server
Apache + Nginx, Nginx + PHP5-FPM
Post Reply
  • Print view
Advanced search
4 posts • Page 1 of 1
dwebb
Posts: 4
Joined: Fri Mar 06, 2020 3:36 pm

Os: Ubuntu 17x
Web: nginx + php-fpm
HTTP downloading php, HTTPS serving php. [SELF-FIXED]
  • Quote

Post by dwebb » Fri Mar 06, 2020 3:46 pm

SERVER-WIDE ISSUE:

I've run into a weird problem. After a server reboot, HTTP requests download php files, but HTTPS requests serve the php files normally.

What should happen: when you goto http://website.com it should auto-redirect you to the website https://website.com. This was working before the server reboot. Sites automatically redirected to the https & everything worked properly. Now when you goto http://website.com you download the .php file, but going to https://website.com serves the website properly.

OS: Ubuntu 18.04
Vesta: 0.9.8 release 26
PHP: PHP 7.2.24-0ubuntu0.18.04.3
Nginx: nginx/1.17.9
Vesta Setup: NGINX + PHP-FPM

Note: Sites, User, & IP have been redacted as "website.com", "X.X.X.X", & "useraccount".

site.nginx.conf

Code: Select all

server {
    listen      X.X.X.X:80;
    server_name website.com www.website.com;
    root        /home/useraccount/web/website.com/public_html;
    index       index.php index.html index.htm;
    access_log  /var/log/nginx/domains/website.com.log combined;
    access_log  /var/log/nginx/domains/website.com.bytes bytes;
    error_log   /var/log/nginx/domains/website.com.error.log error;

    location / {
		try_files $uri $uri/ /index.php?q=$uri&$args;
        location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ {
        expires     max;
	}
        location ~ [^/]\.php(/|$) {
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            if (!-f $document_root$fastcgi_script_name) {
                return  404;
            }
            fastcgi_index   index.php;
			fastcgi_pass    127.0.0.1:9026;
            include         /etc/nginx/fastcgi_params;
			fastcgi_cache phpcache;
			fastcgi_cache_valid 200 301 302 5m;
			fastcgi_cache_use_stale error timeout updating invalid_header http_500 http_503;
			fastcgi_cache_min_uses 1;
			fastcgi_cache_lock on;
			fastcgi_cache_bypass $skip_cache;
			fastcgi_no_cache $skip_cache;
			add_header X-FastCGI-Cache $upstream_cache_status;
        }
    }
	
#Wordpress Caching Start
# POST requests and urls with a query string should always go to PHP
if ($request_method = POST) {
    set $skip_cache 1;
}
if ($query_string != "") {
    set $skip_cache 1;
}

# Don't cache uris containing the following segments
if ($request_uri ~* "/wp-admin/|/xmlrpc.php|wp-.*.php|^/feed/*|/tag/.*/feed/*|index.php|/.*sitemap.*\.(xml|xsl)") {
    set $skip_cache 1;
}

# Don't use the cache for logged in users or recent commenters
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {
    set $skip_cache 1;
}
#Wordpress Caching End

    error_page  403 /error/404.html;
    error_page  404 /error/404.html;
    error_page  500 502 503 504 /error/50x.html;

    location /error/ {
        alias   /home/useraccount/web/website.com/document_errors/;
    }

    location ~* "/\.(htaccess|htpasswd)$" {
        deny    all;
        return  404;
    }

    location /vstats/ {
        alias   /home/useraccount/web/website.com/stats/;
        include /home/useraccount/conf/web/website.com.auth*;
    }

    include     /etc/nginx/conf.d/phpmyadmin.inc*;
    include     /etc/nginx/conf.d/phppgadmin.inc*;
    include     /etc/nginx/conf.d/webmail.inc*;

    include     /home/useraccount/conf/web/snginx.website.com.conf*;
}
nginx.ssl.conf is the same except for :443 ssl http2 & the ssl cert key path

Code: Select all

server {
    listen      X.X.X.X:443 ssl http2;
    server_name website.com www.website.com;
    root        /home/useraccount/web/website.com/public_html;
    index       index.php index.html index.htm;
    access_log  /var/log/nginx/domains/website.com.log combined;
    access_log  /var/log/nginx/domains/website.com.bytes bytes;
    error_log   /var/log/nginx/domains/website.com.error.log error;

    ssl_certificate      /home/useraccount/conf/web/ssl.website.com.pem;
    ssl_certificate_key  /home/useraccount/conf/web/ssl.website.com.key;
I've tried just about everything I can think of to fix this. Any ideas / recommendations?
Last edited by dwebb on Wed Mar 11, 2020 10:25 pm, edited 1 time in total.
Top

dwebb
Posts: 4
Joined: Fri Mar 06, 2020 3:36 pm

Os: Ubuntu 17x
Web: nginx + php-fpm
Re: HTTP downloading php, HTTPS serving php.
  • Quote

Post by dwebb » Wed Mar 11, 2020 8:11 am

Looks like all HTTP requests are garbled:

For example this is what I'm receiving when going to a standard robots.txt on a wordpress site:

�����������€������ےےے�������ے����������������
Top

dwebb
Posts: 4
Joined: Fri Mar 06, 2020 3:36 pm

Os: Ubuntu 17x
Web: nginx + php-fpm
Re: HTTP downloading php, HTTPS serving php.
  • Quote

Post by dwebb » Wed Mar 11, 2020 10:12 pm

Diving further into this issue seems to be much more than a VestaCP problem... I will continue to work on this and post a fix when I get one just in the off chance that someone, somewhere, at sometime stumbles across this.

Image

Looks like the same issue this from this response: https://serverfault.com/a/867022
Top

dwebb
Posts: 4
Joined: Fri Mar 06, 2020 3:36 pm

Os: Ubuntu 17x
Web: nginx + php-fpm
Re: HTTP downloading php, HTTPS serving php.
  • Quote

Post by dwebb » Wed Mar 11, 2020 10:24 pm

....I fixed it.

Client did this in a sites nginx.conf

Code: Select all

server {
listen     :80 http2;
Top


Post Reply
  • Print view

4 posts • Page 1 of 1

Return to “Web Server”



  • Board index
  • All times are UTC
  • Delete all board cookies
  • The team
Powered by phpBB® Forum Software © phpBB Limited
*Original Author: Brad Veryard
*Updated to 3.2 by MannixMD
 

 

cron

Login  •  Register

I forgot my password