doufu2396 2019-02-21 16:58
浏览 99

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.

  • 写回答

1条回答 默认 最新

  • dqm4977 2019-02-25 19:35
    关注

    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

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#python#的问题:求帮写python代码
  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?