Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/268.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 请求中的主体作为响应返回_Php_Docker_Api_Symfony_Nginx - Fatal编程技术网

Php 请求中的主体作为响应返回

Php 请求中的主体作为响应返回,php,docker,api,symfony,nginx,Php,Docker,Api,Symfony,Nginx,我正在将docker与ngnix、php和mysql一起使用。我还使用api平台版本2.6.4。当服务器什么也不做时,当我向端点发出请求时,它将返回正常响应,但也会返回请求体中的json。我试图调试这个,但这不是来自代码,它似乎是形式ngnix或我不知道。但这发生在服务器空闲一段时间后,没有发送任何请求,但当我发送请求时,响应也有请求主体。但这也不适用于所有请求,有时没有请求主体的响应是好的。例如,我向带有主体的登录端点发送post请求 { "email": &quo

我正在将docker与ngnix、php和mysql一起使用。我还使用api平台版本2.6.4。当服务器什么也不做时,当我向端点发出请求时,它将返回正常响应,但也会返回请求体中的json。我试图调试这个,但这不是来自代码,它似乎是形式ngnix或我不知道。但这发生在服务器空闲一段时间后,没有发送任何请求,但当我发送请求时,响应也有请求主体。但这也不适用于所有请求,有时没有请求主体的响应是好的。例如,我向带有主体的登录端点发送post请求

{
    "email": "test@test.eu",
    "password": "password"
}
并得到回应:

{
        "email": "test@test.eu",
        "password": "password"
    }{"token":"eyJ0eXAiOiOtS4wxOtXAdA..."}
这是错误的,有时我会得到正常的反应,比如:

{"token":"eyJ0eXAiOiOtS4wxOtXAdA..."}
这是我的conf文件

[mysql]
extension = pdo_mysql

[intl]
extension = intl

[apcu]
extension = apcu

[sodium]
extension = sodium

[zip]
extension = zip

[php]
apc.enable_cli = 1
date.timezone = Europe/Bratislava
session.auto_start = Off
short_open_tag = Off
expose_php = Off
realpath_cache_size = 4096K
realpath_cache_ttl = 600

[opcache]
zend_extension = opcache

opcache.interned_strings_buffer = 16
opcache.max_accelerated_files = 20000
opcache.memory_consumption = 256
opcache.validate_timestamps = 0
opcache.preload_user=www-data
opcache.preload=/var/www/config/preload.php

这适用于所有修补程序,结束后安装。有人经历过这种行为吗。我试着禁用opcache和apcu,但没有帮助


Thx

问题在于我配置的php容器中确实有开放端口9000(-p 9000:9000)。因此,任何人都可以在服务器发出请求“POST/usr/local/lib/php/PEAR.php 200”后进行攻击。修复此配置并重新安装容器后,一切正常。调试后关闭

此输出来自php://input 但我不知道该如何解决问题,或者问题出在哪里,有什么想法吗?谢谢
user nginx;
worker_processes auto;
daemon off;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;

events {
    worker_connections 1024;
}

http {
    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    access_log /var/log/nginx/access.log;

    sendfile off;
    keepalive_timeout 65;

    gzip on;
    gzip_types text/html application/xml application/ld+json application/json ;

    server {
        server_name localhost;
        root /var/www/public;
    
        location / {
            # try to serve file directly, fallback to app.php
            try_files $uri /index.php$is_args$args;
        }
    
        location ~ ^/index\.php(/|$) {
            # optionally set the value of the environment variables used in the application
            # fastcgi_param APP_ENV prod;
    
            # When you are using symlinks to link the document root to the current version of your application, you should
            # pass the real application path instead of the path to the symlink to PHP FPM. Otherwise, PHP's OPcache may
            # not properly detect changes to your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126).
            fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
            fastcgi_param DOCUMENT_ROOT $realpath_root;
    
            # Bigger buffer size to handle cache invalidation headers expansion
            fastcgi_buffer_size 32k;
            fastcgi_buffers 8 16k;
    
            # Sets the address of a FastCGI server. The address can be specified as a domain name or IP address, and a port
            fastcgi_pass php:9000;
            fastcgi_split_path_info ^(.+\.php)(/.*)$;
            include fastcgi_params;
    
            internal;
       }
    
        # return 404 for all other php files not matching the front controller
        # this prevents access to other php files you don't want to be accessible.
        location ~ \.php$ {
            return 404;
        }
    }

}