How to Enable POST to Static Pages Running via NGINX

I am creating a Facebook Canvas Application, and I wanted to use AngularJS to power the dynamic aspects of it as I need to have a two-way binding between the front and back end.

When I accessed my initial App which was in PHP and downloaded from GitHub it worked fine and retrieved my name just fine. When I switched over to Angular and then accessed the same endpoint through the Facebook Application view, it threw a 405 page error.

The error comes about because NGINX does not by default allow a POST request to be handled by a static (.html) file.

To enable it; SSH onto your box with a suitably permissioned account (I actually use root on this box).

$ sudo vi /etc/nginx/nginx.conf

Look for the configuration for the site/domain in question, and it will either have or need a location block, the you need is below.

location / { error_page 405 =200 $uri;

Please note the 200 after the = is not a typo, it will not work if you add a space. This line just ensures the response is a 200 (OK) response too.

To check the config before you restart, run this command, please do this and make sure the syntax is OK before you restart or the web server will not like it at all:

$ sudo /usr/sbin/nginx -t

That will inform you of any syntax errors, before you restart with:

$ sudo /usr/sbin/nginx -s reload

The page should now handle a POST request without throwing a 405 Error.


A tech native with 20 years of experience across the digital space. Darryl is an evangelist for the power and disruption of blockchain technologies and fosters a passion for bringing ever greater utility and adoption to the masses.

Related Articles

Exploring AI Art with Midjourney: A Handy Cheat Sheet


Driving Startup Success: The Impact of CTO-as-a-Service

Embracing Web3: Safeguarding Data Privacy in the Transparent Digital Era

Copyright © 2016-2023 Bonbon Group Ltd. All Rights Reserved.