上面的 nginx 的配置的语法有什么问题,报错:nginx: [emerg] "proxy_timeout" directive is not allowed here in /etc/nginx/conf.d/default.conf:32
nginx: configuration file /etc/nginx/nginx.conf test failed
http {
upstream backend {
server www.baidu.com;
server www.baidu.com;
server www.baidu.com;
}
server {
listen 80;
server_name example.com;
proxy_timeout 600s;
location / {
proxy_pass http://backend;
proxy_set_header Host $host;
}
}
}
还是不行,还有错误,即便把 proxy_timeout 移动到 server 还是报错
连 nginx 官方的都报错
http {
server {
listen 127.0.0.1:12345;
proxy_pass 127.0.0.1:8080;
}
server {
listen 12345;
proxy_connect_timeout 1s;
proxy_timeout 1m;
proxy_pass example.com:12345;
}
server {
listen 53 udp reuseport;
proxy_timeout 20s;
proxy_pass dns.example.com:53;
}
server {
listen [::1]:12345;
proxy_pass unix:/tmp/stream.socket;
}
}
╰─➤ sudo nginx -t
nginx: [emerg] "proxy_pass" directive is not allowed here in /etc/nginx/nginx.conf:4
nginx: configuration file /etc/nginx/nginx.conf test failed
我知道了,HTTP 没有 proxy_timeout
http://nginx.org/en/docs/http/ngx_http_proxy_module.html
只有 stream 有 proxy_timeout :http://nginx.org/en/docs/stream/ngx_stream_proxy_module.html
看报错proxy_timeout位置不对:
1.http://nginx.org/en/docs/stream/ngx_stream_proxy_module.html
2.https://docs.nginx.com/nginx/admin-guide/load-balancer/tcp-ud...