HTTPS / PHP / NGINX:php://启用HTTPS时输入数据为NULL

This is related to this question. I found that when I checked my HTTPRequest on my YII that Yii::app()->request uses either file_get_contents('php://input') or $HTTP_RAW_POST_DATA to get the request from the front-end. This mechanism works when SSL is disabled yet when enabled, the post data disappears. I saw a similar question but there has been no concrete solution though there is an answer that discourages that use of a 302 redirect when forcing http to https. I need this mechanism on my api server to redirect http to https. How can I allow the redirection of http to https without losing post data? My nginx config is found on this link.

I hope this gets resolved once and for all because I've spent more than a week stuck on this problem.

If you want to redirect http to https, you have to update your nginx conf file.

Nginx should listen to http :

    server {
            listen          80;
            server_name     api.test.com;
            return 301 https://api.test.com$request_uri;
    }

    server {
            listen          443 ssl http2;
            server_name     api.test.com;

            root /var/apps/myapp/current/workspace/api;
            ...

The http2 is optional