参考 : upstream sent invalid chunked response while reading upstream解决_我想问问天的专栏-CSDN博客
nginx版本 : 1.21.1
说明 : nginx80端口运行,当访问80端口但是uri为test开头的转发到8080端口
注 : 本机必须填写局域网ip地址,不能写127.0.0.1
nginx docker 安装 : docker(6) : 安装nginx_Lxinccode的博客-CSDN博客
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
upstream test {
server 192.168.1.1:8080;
}
server {
listen 0.0.0.0:80;
listen [::]:80;
proxy_http_version 1.1;
location /test {
proxy_pass http://test;
proxy_set_header Host $host;
}
}
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
location /test {
proxy_pass http://test;
proxy_set_header Host $host;
}
[ location /test] 只转发/test开头的请求,[ location /]转发所有请求