在 nginx 服务器上请求响应
request in responce on nginx server
我们的后端出于某种原因将请求与响应放在一起。
比如,当 js 发送 post/get/whatever 请求时 name=hello&pass=hell
php 的响应应该是 {result:true}
但我们得到的是 name=hello&pass=hell{result:true}
example screenshot
它 100% 不是 js 或 php 问题,我们在不同的服务器上测试了完全相同的脚本 - 那里没有问题。
我们遇到问题的服务器是 运行 nginx,这是配置的样子。不知道在哪里搜索错误
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= last;
rewrite ^/cb/(.*)$ /lead_cob.php?id= 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每次刷新页面的参数
似乎在 /etc/php/7.4/fpm/pool.d/www.conf
中将 listen
从 9000 更改为 127.0.0.1:9000 解决了请求响应问题
我们的后端出于某种原因将请求与响应放在一起。
比如,当 js 发送 post/get/whatever 请求时 name=hello&pass=hell
php 的响应应该是 {result:true}
但我们得到的是 name=hello&pass=hell{result:true}
example screenshot
它 100% 不是 js 或 php 问题,我们在不同的服务器上测试了完全相同的脚本 - 那里没有问题。
我们遇到问题的服务器是 运行 nginx,这是配置的样子。不知道在哪里搜索错误
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= last;
rewrite ^/cb/(.*)$ /lead_cob.php?id= 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每次刷新页面的参数
似乎在 /etc/php/7.4/fpm/pool.d/www.conf
中将 listen
从 9000 更改为 127.0.0.1:9000 解决了请求响应问题