Nginx the static HTML page POST request 405 returns status data JSON

Access HTML page in a browser, find some static JSON data not shown, F12 view, as shown below:

You can see the request method is POST

The request to copy the link in the browser address bar to access, can be a normal request to the data

F12 view, you can see the request as a way of GET, status code 200

Known issues: Nginx under static HTML pages POST request JSON data returned 405 status, but with the normal GET request to return data.

After Baidu, has said, Apache, IIS, Nginx and so the vast majority of Web servers, static files are not allowed to respond to the POST request.

The following test:

System CentOS7.5, Nginx (Version: 1.16.1) and Apache (Version: 2.4.6) are yum install

after testing:

Apache-2.4.6 POST request may be a normal response

Nginx solution to the following:

Open Nginx configuration file:

vim /etc/nginx/conf.d/default.conf

Add the following configuration at location:

error_page 405 =200 http://$host$request_uri;

systemctl restart nginx

After modifying Nginx configuration file, remember to restart, let it take effect 

Access again with a browser HTML page, F12 view, you can see the way the request is modified to GET, as shown below:

Solution of this article can be: https://my.oschina.net/lemonzone2010/blog/174505 , but the operation would be a little more

Reference article from: https://blog.csdn.net/weixin_30341745/article/details/97532878

 

Guess you like

Origin www.cnblogs.com/opsprobe/p/11961402.html