nginx 代理服务指令详解(2)

         假设前端url是example.com。后端server域名是csdn123.com,那么后端server在返回refresh或location的时候,host为csdn123.com,显然这个信息直接返回给客户端是不行的,需要nginx做转换,这时可以设置:

          proxy_redirect http://csdn123.com

nginx会将host及port部分替换成自身的server_name及listen port。不过这种配置对server_name有多个值的情况下支持不好。
我们可以用nginx内部变量来解决这一问题:

        proxy_redirect http://csdn123.com $host:$server_port

     17, proxy_intercept_errors

        配置一个状态的开启或者关闭

        proxy_intercept_errors on | off

     18, proxy_headers_hash_max_size

        存放HTTP报文头的哈希表的容量

        proxy_headers_hash_max_size size; 默认大小512

     19, proxy_headers_hash_bucket_size

        Nginx服务器申请存放HTTP报文头的哈希表容量的单位大小

        proxy_headers_hash_max_size 64;

     20, proxy_next_upstream

        如果Nginx定义了 upstream 后端服务器组,如果组内有异常情况,将请求顺次交给下一个组内服务器处理

        proxy_next_upstream status...

        status: error,timeout,invalid_header,http_500 502 503 504 404,off

     21, proxy_ssl_session_reuse

        该指令用于配置是否使用基于SSL安全协议的会话连接(htts://)被代理服务器,

        proxy_ssl_session_reuse on | off; 默认on

Proxy Buffer 指令详解:

     22,  proxy_buffering

        用于配置是否启用或者关闭proxybuff

        proxy_buffering on | off

��    23,  proxy_buffers 

        用于配置接收一次被代理服务器响应数据的Proxy Buffer个数和每个Buffer的大小.

        proxy_buffers number size;

        size一般设置为内存页大小.根据平台的不同,取值可能为4KB或者8KB

        proxy_buffers 8 4KB|8KB;

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/5644d11e22d4d1cc7e6a246442f6d891.html