Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Server
User Name
Linux - Server This forum is for the discussion of Linux Software used in a server related context.


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

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.
It shows up on https when I hit the home page URL ( but when I enter the forum address ( I get an error "500 Internal Server Error". (please check picture attachment)

The following error is displayed when I check the Nginx logs.
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:, server:, request: "GET /forums/ HTTP/1.1", 
upstream: "fastcgi://", host: "", 
referrer: ""
The settings for my Nginx are as follows :
server { ## listen for ipv4

        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_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/; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/; # 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/;

server {

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

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

        listen   80;
    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:	233
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
Senior Member
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.7.1908
Posts: 4,551

Rep: Reputation: 1641Reputation: 1641Reputation: 1641Reputation: 1641Reputation: 1641Reputation: 1641Reputation: 1641Reputation: 1641Reputation: 1641Reputation: 1641Reputation: 1641
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
Senior Member
Registered: Feb 2011
Distribution: Ubuntu, Centos
Posts: 1,072

Rep: Reputation: 79
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 then go to and if you're accessing then go to It's as if you're serving to different websites.
Just do a return 301 https://$host$request_uri; without any conditionals whatsoever.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 to 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 > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 11:20 PM.

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