Nginx反代

vi /etc/nginx/conf.d/proxy.conf

server {
  listen 80;
  server_name test.com;

  location / {
     proxy_pass http://www.qq.com;
     }
}

            2、proxy_set_header field value;
                设定发往后端主机的请求报文的请求首部的值;Context:    http, server, location
                
                proxy_set_header X-Real-IP  $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                
            3、proxy_cache_path
                定义可用于proxy功能的缓存;Context:    http            
                
                proxy_cache_path path [levels=levels] [use_temp_path=on|off] keys_zone=name:size [inactive=time] [max_size=size] [manager_files=number] [manager_sleep=time] [manager_threshold=time] [loader_files=number] [loader_sleep=time] [loader_threshold=time] [purger=on|off] [purger_files=number] [purger_sleep=time] [purger_threshold=time];
                
            4、proxy_cache zone | off;
                指明要调用的缓存,或关闭缓存机制;Context:    http, server, location
                
            5、 proxy_cache_key string;
                缓存中用于“键”的内容;
                
                默认值:proxy_cache_key $scheme$proxy_host$request_uri;
                
            6、proxy_cache_valid [code ...] time;
                定义对特定响应码的响应内容的缓存时长;
                
                定义在http{...}中;
                proxy_cache_path /var/cache/nginx/proxy_cache levels=1:1:1 keys_zone=pxycache:20m max_size=1g;
                
                定义在需要调用缓存功能的配置段,例如server{...};
                proxy_cache pxycache;
                proxy_cache_key $request_uri;
                proxy_cache_valid 200 302 301 1h;
                proxy_cache_valid any 1m;
                
            7、proxy_cache_use_stale
                
                proxy_cache_use_stale error | timeout | invalid_header | updating | http_500 | http_502 | http_503 | http_504 | http_403 | http_404 | off ...;
                
                Determines in which cases a stale cached response can be used when an error occurs during communication with the proxied server.
                
            8、proxy_cache_methods GET | HEAD | POST ...;
                If the client request method is listed in this directive then the response will be cached. “GET” and “HEAD” methods are always added to the list, though it is recommended to specify them explicitly. 
                
            9、proxy_hide_header field;
                By default, nginx does not pass the header fields “Date”, “Server”, “X-Pad”, and “X-Accel-...” from the response of a proxied server to a client. The proxy_hide_header directive sets additional fields that will not be passed.
                
            10、proxy_connect_timeout time;
                Defines a timeout for establishing a connection with a proxied server. It should be noted that this timeout cannot usually exceed 75 seconds.
                
                默认为60s;最长为75s;
                
            11、proxy_read_timeout time; 
                Defines a timeout for reading a response from the proxied server. The timeout is set only between two successive read operations, not for the transmission of the whole response.
                
            12、proxy_send_timeout time;
                Sets a timeout for transmitting a request to the proxied server. he timeout is set only between two successive write operations, not for the transmission of the whole request. If the proxied server does not receive anything within this time, the connection is closed. 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

金牌收租佬

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值