Web Server Switched to nginx - MyFAQ Completely Broken

Please report bugs here!

Moderator: Thorsten

Post Reply
own3mall
Posts: 2
Joined: Sat Oct 31, 2015 6:18 pm

Web Server Switched to nginx - MyFAQ Completely Broken

Post by own3mall »

Hi Guys,

I recently switched my web server from apache2 to nginx. After doing so, I noticed that nothing works anymore in my installation of PHPMyFAQ. I am running an older version, but it should still work. All I did was switch over to nginx. The rewrite rules option is disabled according to my settings in the MySQL database. Also, SSL is off too, but it still tries to redirect my logins to HTTPS, and I'm not sure why. Nothing loads anymore. Does anyone know what I need to do to get it working again?

Here is my installation (running phpMyFAQ 2.7.9):

http://ehcpforce.tk/faq/

Settings in my DB:
security.useSslForLogins false
security.useSslOnly false
main.enableRewriteRules false
Thorsten
Posts: 15561
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: Web Server Switched to nginx - MyFAQ Completely Broken

Post by Thorsten »

Hi,

looks like something in your nginx is wrong as all JavaScript and CSS files return an aborted HTTP response. Please check your nginx error log.

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
own3mall
Posts: 2
Joined: Sat Oct 31, 2015 6:18 pm

Re: Web Server Switched to nginx - MyFAQ Completely Broken

Post by own3mall »

Thorsten wrote:Hi,

looks like something in your nginx is wrong as all JavaScript and CSS files return an aborted HTTP response. Please check your nginx error log.

bye
Thorsten
Yes, because it is trying to load the script files via HTTPS (SSL) when it should be using HTTP (NON SECURE).

After looking on the net for a while, I found this:

http://dev.cmsmadesimple.org/bug/view/9559

Which means the logic in Link.php:

Code: Select all

    public static function getSystemScheme()
    {
        if (PMF_Configuration::getInstance()->get('security.useSslOnly')) {
            return 'https://';
        }
        
        $scheme = 'http' . (((!PMF_Link::isIISServer()) && isset($_SERVER['HTTPS'])) || 
                           ((PMF_Link::isIISServer()) && ('on' == strtolower($_SERVER['HTTPS']))) ? 's' : '') . '://';

        return $scheme;
    }
Is not correct. $_SERVER['HTTPS'] isset but has an empty value on nginx.

So, I changed this function to:

Code: Select all

    public static function getSystemScheme()
    {
        if (PMF_Configuration::getInstance()->get('security.useSslOnly')) {
            return 'https://';
        }
        
        $scheme = 'http' . (((!PMF_Link::isIISServer()) && (isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']))) || 
                           ((PMF_Link::isIISServer()) && ('on' == strtolower($_SERVER['HTTPS']))) ? 's' : '') . '://';

        return $scheme;
    }

And, I'm back in business. Hopefully this will help others, and maybe the code should be changed to check for HTTPS in a different manner?
Thorsten
Posts: 15561
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: Web Server Switched to nginx - MyFAQ Completely Broken

Post by Thorsten »

Hi,

that issue was fixed in 2.8: https://github.com/thorsten/phpMyFAQ/bl ... #L423-L449

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
Post Reply