首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在nginx服务器上请求响应

在nginx服务器上请求响应
EN

Stack Overflow用户
提问于 2021-06-30 09:30:15
回答 1查看 122关注 0票数 0

出于某种原因,我们的后端将请求与响应结合在一起。

比如,当js用name=hello&pass=hell发送post/get/任何请求时

php的响应应该是{result:true}

但是我们得到的是name=hello&pass=hell{result:true}

示例截图

它的100%不是js或php问题,我们在不同的服务器上测试了相同的脚本--没有问题。

我们遇到问题的服务器正在运行nginx,下面是配置的样子。不知道在哪里搜索错误

代码语言:javascript
复制
user www-data;
worker_processes auto;
worker_rlimit_nofile 65535;
pid /var/run/nginx.pid;

events {
    worker_connections 100000;
    multi_accept on;
}

http {
    ## Basic Settings ##
    client_body_timeout             20s; # Use 5s for high-traffic sites
    client_header_timeout           20s; # Use 5s for high-traffic sites
    client_max_body_size            1024m;
    keepalive_timeout               20s;
    port_in_redirect                off;
    sendfile                        on;
    server_names_hash_bucket_size   64;
    server_name_in_redirect         off;
    server_tokens                   off;
    tcp_nodelay                     on;
    tcp_nopush                      on;
    types_hash_max_size             2048;

    ## DNS Resolver ##
    # If in China, enable the OpenDNS entry that matches your network connectivity (IPv4 only or IPv4 & IPv6)
    # OpenDNS (IPv4 & IPv6)
    #resolver                       208.67.222.222 208.67.220.220 [2620:0:ccc::2] [2620:0:ccd::2];
    # OpenDNS (IPv4 only)
    #resolver                       208.67.222.222 208.67.220.220;
    # Google Public DNS (IPv4 & IPv6)
    #resolver                       8.8.8.8 8.8.4.4 [2001:4860:4860::8888] [2001:4860:4860::8844];
    # Google Public DNS (IPv4 only) [default]
    resolver                        8.8.8.8 8.8.4.4;

        ##
        # Protect Dos
        ##
        limit_req_zone $binary_remote_addr zone=dos:10m rate=4000r/s;
        limit_req zone=dos burst=1000;
        limit_req_status 503;


    ## MIME ##
    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    ## Logging Settings ##
    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    ## Gzip Settings ##
    gzip on;
    gzip_buffers 16 8k;
    gzip_comp_level 5;
    gzip_disable "msie6";
    gzip_min_length 256;
    gzip_proxied any;
    gzip_types
        application/atom+xml
        application/javascript
        application/json
        application/ld+json
        application/manifest+json
        application/rss+xml
        application/vnd.geo+json
        application/vnd.ms-fontobject
        application/x-font-ttf
        application/x-javascript
        application/x-web-app-manifest+json
        application/xhtml+xml
        application/xml
        font/opentype
        image/bmp
        image/svg+xml
        image/x-icon
        text/cache-manifest
        text/css
        text/javascript
        text/plain
        text/vcard
        text/vnd.rim.location.xloc
        text/vtt
        text/x-component
        text/x-cross-domain-policy
        text/x-js
        text/xml;
    gzip_vary on;

    # Proxy Settings
    proxy_cache_path /tmp/engintron_dynamic levels=1:2 keys_zone=engintron_dynamic:20m inactive=10m max_size=500m;
    proxy_cache_path /tmp/engintron_static levels=1:2 keys_zone=engintron_static:20m inactive=10m max_size=500m;
    proxy_temp_path /tmp/engintron_temp;

    ## Virtual Host Configs ##
    include /etc/nginx/conf.d/*.conf;
        

server {
        listen 80 default_server;
        listen [::]:80 default_server;

        root /var/www/html;

        index index.php index.html index.htm index.nginx-debian.html;

        server_name [censored];

        location / {
                try_files $uri $uri/ =404;
        }

       location ~ \.php$ {
                                   try_files $uri /index.php =404;
                                   fastcgi_pass localhost:9000;
                                   fastcgi_index index.php;
                                   fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                                   include fastcgi_params;

                           }

        location ~ /\.ht {
                deny all;
        }
}

server {
        server_name brokenshit.[censored].com www.brokenshit.[censored].com;

        root /var/www/html/Production;
        index index.php;

        rewrite ^/l/(.*)$ /lead_details.php?id=$1 last;
        rewrite ^/cb/(.*)$ /lead_cob.php?id=$1 last;

        location / {
                try_files $uri $uri/ /index.php?$args;
        }

        location ~ \.php$ {
                try_files $uri /index.php =404;
                fastcgi_pass localhost:9000;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
        }
    }
}

更新

将邮递员的请求发送到此服务器-没有问题,正常响应没有任何不必要的字符串。

更新2

  • service php7.4-fpm restart在很短的时间内会有所帮助
  • auto_prepend_file = none in php.ini在短时间内有所帮助
  • 实际上,每次刷新页面时,pfpinfo();都显示不同的auto_prepend_file、allow_url_include和disable_functions参数。
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-07-09 09:20:24

似乎把listen9000改为/etc/php/7.4/fpm/pool.d/www.conf中的解决了请求的响应问题。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68192115

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档