这是我参与11月更文挑战的第21天,活动详情查看:2021最后一次更文挑战
nginx是一种服务端的负载均衡代理,Http代理,反向代理:作为web服务器最常用的功能之一,尤其是反向代理。Nginx在做反向代理时,提供性能稳定,并且能够提供配置灵活的转发功能。Nginx可以根据不同的正则匹配,采取不同的转发策略。本篇博主将收集到的配置选项总结出来,供小伙伴们参考。
1 | ini复制代码#user nobody; #配置用户或者组,默认为nobody nobody。 |
2.其他配置
- include mime.types; #文件扩展名与文件类型映射表
- default_type application/octet-stream; #默认文件类型,默认为text/plain
- #access_log off; #取消服务日志
- log_format myFormat ‘ remoteaddr–remote_addr–remoteaddr–remote_user [timelocal]time_local] timelocal]request statusstatus statusbody_bytes_sent httprefererhttp_referer httprefererhttp_user_agent $http_x_forwarded_for’; #自定义格式
- access_log log/access.log myFormat; #combined为日志格式的默认值
- sendfile on; #允许sendfile方式传输文件,默认为off,可以在http块,server块,location块。
- sendfile_max_chunk 100k; #每个进程每次调用传输数量不能大于设定的值,默认为0,即不设上限。
- keepalive_timeout 65; #连接超时时间,默认为75s,可以在http,server,location块。
- proxy_connect_timeout 1; #nginx服务器与被代理的服务器建立连接的超时时间,默认60秒
- proxy_read_timeout 1; #nginx服务器想被代理服务器组发出read请求后,等待响应的超时间,默认为60秒。
- proxy_send_timeout 1; #nginx服务器想被代理服务器组发出write请求后,等待响应的超时间,默认为60秒。
- proxy_http_version 1.0 ; #Nginx服务器提供代理服务的http协议版本1.0,1.1,默认设置为1.0版本。
- #proxy_method get; #支持客户端的请求方法。post/get;
- proxy_ignore_client_abort on; #客户端断网时,nginx服务器是否终端对被代理服务器的请求。默认为off。
- proxy_ignore_headers “Expires” “Set-Cookie”; #Nginx服务器不处理设置的http相应投中的头域,这里空格隔开可以设置多个。
- proxy_intercept_errors on; #如果被代理服务器返回的状态码为400或者大于400,设置的error_page配置起作用。默认为off。
- proxy_headers_hash_max_size 1024; #存放http报文头的哈希表容量上限,默认为512个字符。
- proxy_headers_hash_bucket_size 128; #nginx服务器申请存放http报文头的哈希表容量大小。默认为64个字符。
- proxy_next_upstream timeout; #反向代理upstream中设置的服务器组,出现故障时,被代理服务器返回的状态值。error|timeout|invalid_header|http_500|http_502|http_503|http_504|http_404|off
- #proxy_ssl_session_reuse on; 默认为on,如果我们在错误日志中发现“SSL3_GET_FINSHED:digest check failed”的情况时,可以将该指令设置为off。
本文转载自: 掘金