LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 03-25-2020, 11:53 AM   #1
aria_redhat
LQ Newbie
 
Registered: Dec 2019
Posts: 14

Rep: Reputation: Disabled
Problem in redirect domain to https in Nginx


Hi. I use the vBulletin Maker Community. I just migrated from http to https recently and used the Certbot app to do that. Certbot automatically added certificates and domain redirects from http to https in the defualt.conf settings on the Nginx web server. vBulletin is embedded within the forums directory on the root of Nginx web server.
Code:
mysite.com/forums
It shows up on https when I hit the home page URL (https://mysite.com) but when I enter the forum address (https://mysite.com/forums) I get an error "500 Internal Server Error". (please check picture attachment)


The following error is displayed when I check the Nginx logs.
Code:
2020/03/25 08:45:03 [error] 5632#5632: *1 FastCGI sent in stderr: "PHP message: PHP Warning:  
count(): Parameter must be an array or an object that implements 
Countable in /usr/share/nginx/html/forums/includes/vb5/template.php(392) : eval()'d code on line 457" while reading response header from upstream, 
client: 10.250.20.143, server: mysite.com, request: "GET /forums/ HTTP/1.1", 
upstream: "fastcgi://127.0.0.1:9000", host: "mysite.com", 
referrer: "https://mysite.com/forums/"
The settings for my Nginx are as follows :
Code:
server { ## listen for ipv4
        server_name      mysite.com www.mysite.com;

        root   /usr/share/nginx/html;
        index   index.php index.html index.htm;
	rewrite /forums/css.php$    /forums/core/css.php  last;
	
	client_max_body_size 20M;
    	large_client_header_buffers 4 16k;
	
	# log files, uncomment and set proper values
        access_log      /var/log/nginx/access.log;
        error_log       /var/log/nginx/error.log;

	# configuration rules
        # legacy css being handled separate for performance
        location = /css\.php {
                rewrite ^ /core/css.php break;
        }

        # make install available from presentation
        location ^~ /forums/install {
                rewrite ^/forums/install/ /forums/core/install/ break;
        }

 
	# any request to not existing item gets redirected through routestring
        location /forums/ {
        	if (!-f $request_filename) {
        	rewrite ^/forums/(.*)$ /forums/index.php?routestring=$1 last;
        	}
        }

        # make admincp available from presentation
        location ^~ /forums/admincp {
                if (!-f $request_filename) {
                        rewrite ^/forums/admincp/(.*)$ /forums/index.php?routestring=admincp/$1 last;
                }
        }

	# login admincp codes
	location ~ /forums/(?!index)[^/]+\.php$ {
	        if (!-f $request_filename) {
		rewrite ^/forums/(.*) /forums/index.php?routestring=$1 last;
		}
	}

        # process any php scripts, not found gets redirected through routestring
        location ~ \.php$ {
                # handles legacy scripts
                if (!-f $request_filename) {
                        rewrite ^/(.*)$ /index.php?routestring=$1 break;
                }

                fastcgi_split_path_info ^(.+\.php)(.*)$;
		try_files $fastcgi_script_name =404;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include /etc/nginx/fastcgi_params;
                fastcgi_param QUERY_STRING $query_string;
                fastcgi_param REQUEST_METHOD $request_method;
                fastcgi_param CONTENT_TYPE $content_type;
                fastcgi_param CONTENT_LENGTH $content_length;
                fastcgi_intercept_errors on;
                fastcgi_ignore_client_abort off;
                fastcgi_connect_timeout 60;
                fastcgi_send_timeout 180;
                fastcgi_read_timeout 180;
                fastcgi_buffers 256 16k;
                fastcgi_buffer_size 32k;
                fastcgi_temp_file_write_size 256k;
        }
	
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/mysite.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/mysite.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot


}

upstream phpfastcgi {
	# address to accept FastCGI requests. Make sure you set the right value under your fast cgi conf.
	server    unix:/var/run/php-fpm/php-fpm.pid;
}

server {
  

    if ($host = www.mysite.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    if ($host = mysite.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


        listen   80;
        server_name      mysite.com www.mysite.com;
    return 404; # managed by Certbot

}

Where can the problem be? And how can I solve the problem?

My scenario specifications are as follows:

OS : CentOS 7
PHP : 7.3
MariaDB : 10
Nginx : 1.16
Attached Thumbnails
Click image for larger version

Name:	nginx 500 error.png
Views:	244
Size:	99.1 KB
ID:	32861  

Last edited by aria_redhat; 03-27-2020 at 02:27 AM.
 
Old 03-27-2020, 12:42 AM   #2
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,735

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Gad, that post is hard to read!! Please use code tags instead of phpcode tags...

I don’t think your problems with redirect, but with the forum installation/setup. The web log files may give more information.
 
Old 03-31-2020, 01:41 PM   #3
vincix
Senior Member
 
Registered: Feb 2011
Distribution: Ubuntu, Centos
Posts: 1,240

Rep: Reputation: 103Reputation: 103
I don't see either how this has anything to do with your https redirect.
On the other hand, I wouldn't recommend using the if conditionals, it wastes ressources. And the redirect doesn't make much sense. It says, if you're accessing myhost.com then go to https://myhost.com and if you're accessing www.myhost.com then go to https://www.myhost.com. It's as if you're serving to different websites.
Just do a return 301 https://$host$request_uri; without any conditionals whatsoever.
 
Old 05-17-2021, 01:50 PM   #4
aria_redhat
LQ Newbie
 
Registered: Dec 2019
Posts: 14

Original Poster
Rep: Reputation: Disabled
Thank you. My problem was solved.

In the www.conf file, I changed the listen line to the following value and the problem was solved.
Code:
listen = 127.0.0.1:9000
 
Old 05-17-2021, 02:10 PM   #5
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,689

Rep: Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972
Quote:
Originally Posted by aria_redhat View Post
Thank you. My problem was solved.

In the www.conf file, I changed the listen line to the following value and the problem was solved.
Code:
listen = 127.0.0.1:9000
Actually no...it's not solved, you just hid the problem. As with your other thread:
https://www.linuxquestions.org/quest...nx-4175694959/

...you're doing this to avoid fixing the software/pages, which is the actual fix you need, rather than just ignoring the problem. Things are only going to get worse if they're ignored.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Trailing slash issue with https to http redirect (Nginx/BitrixVM/CentOS6.5) Akram03 Linux - General 0 02-21-2016 04:10 PM
[SOLVED] Trailing slash issue with https redirect - Nginx linson_85 Linux - General 2 09-23-2015 11:43 PM
Nginx, Horde, Https, Redirect, This webpage has a redirect loop axetone Ubuntu 0 02-08-2015 10:44 PM
redirect https://www.domain.com to https://domain.com decenter Linux - Server 4 09-13-2011 10:05 AM
apache 2.0 https to https redirect struct Linux - Software 1 04-22-2011 05:43 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 01:58 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration