XF 1.2 Returning HTTP 503 Error Codes with Nginx During Maintenance

DeltaHF

Well-known member
I'm going to convert my vBulletin forum to XenForo, and I want to close off the /forum/ subdirectory of my site during the process and return a custom 503 error page. Of course, I still need to be able to access the subdirectory from my IP address while this is going on. I'm using Nginx and PHP-FPM.

Here's my first attempt at a relevant location block, assuming my IP address is 0.0.0.0. It blocks public requests to static files in the /forum/ directory, but PHP files can still be accessed by anyone.

Code:
        location ^~ /forum/
        {
                if ($remote_addr != "0.0.0.0")
                {
                        return 503;
                }

                include /usr/local/nginx/conf/php.conf;
        }

If I remove the "include" which loads in my php.conf, then I can't execute PHP files in the directory myself, which is obviously a requirement. Any ideas how I can get this working?
 
Thanks. That does stop the PHP scripts from being executed.

Now I just need to figure out how to get "deny all" to throw a 503 instead of a 403.

EDIT: Yeah, doesn't look like there's any way to do that... I don't want to return 403's while my forum is converting. Ugh. Is there really no way to do this?

EDIT 2: I figured this out! See http://serverfault.com/a/544056/192616.
 
Last edited:
Top Bottom