Nginx(十三) 配置文件详解 - 反向代理(超详细)

发布时间:2023年12月30日

? ? ? ? 本篇文章主要讲ngx_http_proxy_module模块下各指令的使用方法。

1.?proxy_bind

Syntax:? ? ?proxy_bind address [transparent] | off;
Default:? ? ?—
Context:?? ?http, server, location
This directive appeared in version 0.8.22.

2.?proxy_buffer_size

Syntax:? ? ?proxy_buffer_size size;
Default:? ? ?proxy_buffer_size 4k|8k;
Context:?? ?http, server, location

3.?proxy_buffering

Syntax:? ? ?proxy_buffering on | off;
Default:? ? ?proxy_buffering on;
Context:?? ?http, server, location

4.?proxy_buffers

Syntax:? ? ?proxy_buffers number size;
Default:? ? ?proxy_buffers 8 4k|8k;
Context:?? ?http, server, location

5.?proxy_busy_buffers_size

Syntax:? ? ?proxy_busy_buffers_size size;
Default:? ? ?proxy_busy_buffers_size 8k|16k;
Context:?? ?http, server, location

?6. proxy_cache

?6.1?proxy_cache

Syntax:?? ?proxy_cache zone | off;
Default:?? ?proxy_cache off;
Context:?? ?http, server, location

6.2?proxy_cache_background_update

Syntax:?? ?proxy_cache_background_update on | off;
Default:?? ?proxy_cache_background_update off;
Context:?? ?http, server, location
This directive appeared in version 1.11.10.

6.3?proxy_cache_bypass

Syntax:?? ?proxy_cache_bypass string ...;
Default:?? ?—
Context:?? ?http, server, location

6.4?proxy_cache_convert_head

Syntax:?? ?proxy_cache_convert_head on | off;
Default:?? ?proxy_cache_convert_head on;
Context:?? ?http, server, location
This directive appeared in version 1.9.7.

6.5?proxy_cache_key?

Syntax:?? ?proxy_cache_key string;
Default:?? ?proxy_cache_key $scheme$proxy_host$request_uri;
Context:?? ?http, server, location

6.6?proxy_cache_lock?

Syntax:?? ?proxy_cache_lock on | off;
Default:?? ?proxy_cache_lock off;
Context:?? ?http, server, location
This directive appeared in version 1.1.12.

6.7?proxy_cache_lock_age?

Syntax:?? ?proxy_cache_lock_age time;
Default:?? ?proxy_cache_lock_age 5s;
Context:?? ?http, server, location
This directive appeared in version 1.7.8.

6.8?proxy_cache_lock_timeout?

Syntax:?? ?proxy_cache_lock_timeout time;
Default:?? ?proxy_cache_lock_timeout 5s;
Context:?? ?http, server, location
This directive appeared in version 1.1.12.

6.9?proxy_cache_max_range_offset?

Syntax:?? ?proxy_cache_max_range_offset number;
Default:?? ?—
Context:?? ?http, server, location
This directive appeared in version 1.11.6.

6.10?proxy_cache_methods?

Syntax:?? ?proxy_cache_methods GET | HEAD | POST ...;
Default:?? ?proxy_cache_methods GET HEAD;
Context:?? ?http, server, location
This directive appeared in version 0.7.59.

6.11?proxy_cache_min_uses??

Syntax:?? ?proxy_cache_min_uses number;
Default:?? ?proxy_cache_min_uses 1;
Context:?? ?http, server, location

6.12?proxy_cache_path?

Syntax:?? ?proxy_cache_path path [levels=levels] [use_temp_path=on|off] keys_zone=name:size [inactive=time] [max_size=size] [min_free=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];
Default:?? ?—
Context:?? ?http

6.13?proxy_cache_purge?

Syntax:?? ?proxy_cache_purge string ...;
Default:?? ?—
Context:?? ?http, server, location
This directive appeared in version 1.5.7.

6.14?proxy_cache_revalidate??

Syntax:?? ?proxy_cache_revalidate on | off;
Default:?? ?proxy_cache_revalidate off;
Context:?? ?http, server, location
This directive appeared in version 1.5.7.

6.15?proxy_cache_use_stale??

Syntax:?? ?proxy_cache_use_stale error | timeout | invalid_header | updating | http_500 | http_502 | http_503 | http_504 | http_403 | http_404 | http_429 | off ...;
Default:???proxy_cache_use_stale off;
Context:?? ?http, server, location

6.16?proxy_cache_valid?

Syntax:?? ?proxy_cache_valid [code ...] time;
Default:?? ?—
Context:?? ?http, server, location

7.?proxy_connect_timeout?

Syntax:?? ?proxy_connect_timeout time;
Default:?? ?proxy_connect_timeout 60s;
Context:?? ?http, server, location

8. proxy_cookie?

8.1?proxy_cookie_domain??

Syntax:?? ?proxy_cookie_flags off | cookie [flag ...];
Default:?? ?proxy_cookie_flags off;
Context:?? ?http, server, location
This directive appeared in version 1.19.3.

8.2?proxy_cookie_flags?

Syntax:?? ?proxy_cookie_flags off | cookie [flag ...];
Default:?? ?
proxy_cookie_flags off;
Context:?? ?http, server, location
This directive appeared in version 1.19.3.

8.3?proxy_cookie_path?

Syntax:?? ?proxy_cookie_path off;
????????????????proxy_cookie_path path replacement;
Default:?? ?proxy_cookie_path off;
Context:?? ?http, server, location
This directive appeared in version 1.1.15.

9.?proxy_force_ranges?

Syntax:?? ?proxy_force_ranges on | off;
Default:?? ?proxy_force_ranges off;
Context:?? ?http, server, location
This directive appeared in version 1.7.7.

10.?proxy_headers_hash_bucket_size??

Syntax:?? ?proxy_headers_hash_bucket_size size;
Default:?? ?proxy_headers_hash_bucket_size 64;
Context:?? ?http, server, location

11.?proxy_headers_hash_max_size?

Syntax:?? ?proxy_headers_hash_max_size size;
Default:?? ?proxy_headers_hash_max_size 512;
Context:?? ?http, server, location

12.?proxy_hide_header?

Syntax:?? ?proxy_hide_header field;
Default:?? ?—
Context:?? ?http, server, location

13.?proxy_http_version?

Syntax:?? ?proxy_http_version 1.0 | 1.1;
Default:?? ?proxy_http_version 1.0;
Context:?? ?http, server, location
This directive appeared in version 1.1.4.

14.?proxy_ignore_client_abort?

Syntax:?? ?proxy_ignore_client_abort on | off;
Default:?? ?proxy_ignore_client_abort off;
Context:?? ?http, server, location

15.?proxy_ignore_headers?

Syntax:?? ?proxy_ignore_headers field ...;
Default:?? ?—
Context:?? ?http, server, location

16.?proxy_intercept_errors?

Syntax:?? ?proxy_intercept_errors on | off;
Default:?? ?proxy_intercept_errors off;
Context:?? ?http, server, location

17.?proxy_limit_rate?

Syntax:?? ?proxy_limit_rate rate;
Default:?? ?proxy_limit_rate 0;
Context:?? ?http, server, location
This directive appeared in version 1.7.7.

18.?proxy_max_temp_file_size?

Syntax:?? ?proxy_max_temp_file_size size;
Default:?? ?proxy_max_temp_file_size 1024m;
Context:?? ?http, server, location

19.?proxy_method?

Syntax:?? ?proxy_method method;
Default:?? ?—
Context:?? ?http, server, location

20.?proxy_next_upstream?

20.1?proxy_next_upstream?

Syntax:?? ?proxy_next_upstream error | timeout | invalid_header | http_500 | http_502 | http_503 | http_504 | http_403 | http_404 | http_429 | non_idempotent | off ...;
Default:?? ?proxy_next_upstream error timeout;
Context:?? ?http, server, location

20.2?proxy_next_upstream_timeout?

Syntax:?? ?proxy_next_upstream_timeout time;
Default:?? ?proxy_next_upstream_timeout 0;
Context:?? ?http, server, location
This directive appeared in version 1.7.5.

20.3?proxy_next_upstream_tries?

Syntax:?? ?proxy_next_upstream_tries number;
Default:?? ?proxy_next_upstream_tries 0;
Context:?? ?http, server, location
This directive appeared in version 1.7.5.

21.?proxy_no_cache?

Syntax:?? ?proxy_no_cache string ...;
Default:?? ?—
Context:?? ?http, server, location

22.?proxy_pass?

22.1?proxy_pass?

Syntax:?? ?proxy_pass URL;
Default:?? ?—
Context:?? ?location, if in location, limit_except

22.2?proxy_pass_header?

Syntax:?? ?proxy_pass_header field;
Default:?? ?—
Context:?? ?http, server, location

22.3?proxy_pass_request_body?

Syntax:?? ?proxy_pass_request_body on | off;
Default:?? ?proxy_pass_request_body on;
Context:?? ?http, server, location

22.4?proxy_pass_request_headers?

Syntax:?? ?proxy_pass_request_headers on | off;
Default:?? ?proxy_pass_request_headers on;
Context:?? ?http, server, location

23.?proxy_read_timeout?

Syntax:?? ?proxy_read_timeout time;
Default:?? ?proxy_read_timeout 60s;
Context:?? ?http, server, location

24.?proxy_redirect?

Syntax:?? ?proxy_redirect default;
????????????????proxy_redirect off;
????????????????proxy_redirect redirect replacement;
Default:?? ?proxy_redirect default;
Context:?? ?http, server, location

25.?proxy_request_buffering?

Syntax:?? ?proxy_request_buffering on | off;
Default:?? ?proxy_request_buffering on;
Context:?? ?http, server, location
This directive appeared in version 1.7.11.

26.?proxy_send_lowat?

Syntax:?? ?proxy_send_lowat size;
Default:?? ?proxy_send_lowat 0;
Context:?? ?http, server, location

27.?proxy_send_timeout?

Syntax:?? ?proxy_send_timeout time;
Default:?? ?proxy_send_timeout 60s;
Context:?? ?http, server, location

28.?proxy_set_body?

Syntax:?? ?proxy_set_body value;
Default:?? ?—
Context:?? ?http, server, location

29.?proxy_set_header?

Syntax:?? ?proxy_set_header field value;
Default:?? ?proxy_set_header Host $proxy_host;
? ? ? ? ? ? ? ? ?proxy_set_header Connection close;
Context:?? ?http, server, location

30.?proxy_socket_keepalive?

Syntax:?? ?proxy_socket_keepalive on | off;
Default:?? ?proxy_socket_keepalive off;
Context:?? ?http, server, location
This directive appeared in version 1.15.6.

31.?proxy_ssl

31.1?proxy_ssl_certificate?

Syntax:?? ?proxy_ssl_certificate file;
Default:?? ?—
Context:?? ?http, server, location
This directive appeared in version 1.7.8.

31.2?proxy_ssl_certificate_key?

Syntax:?? ?proxy_ssl_certificate_key file;
Default:?? ?—
Context:?? ?http, server, location
This directive appeared in version 1.7.8.

31.3?proxy_ssl_ciphers?

Syntax:?? ?proxy_ssl_ciphers ciphers;
Default:?? ?proxy_ssl_ciphers DEFAULT;
Context:?? ?http, server, location
This directive appeared in version 1.5.6.

31.4?proxy_ssl_conf_command?

Syntax:?? ?proxy_ssl_conf_command name value;
Default:?? ?—
Context:?? ?http, server, location
This directive appeared in version 1.19.4.

31.5?proxy_ssl_crl?

Syntax:?? ?proxy_ssl_crl file;
Default:?? ?—
Context:?? ?http, server, location
This directive appeared in version 1.7.0.

31.6?proxy_ssl_name?

Syntax:?? ?proxy_ssl_name name;
Default:?? ?proxy_ssl_name $proxy_host;
Context:?? ?http, server, location
This directive appeared in version 1.7.0.

31.7?proxy_ssl_password_file?

Syntax:?? ?proxy_ssl_password_file file;
Default:?? ?—
Context:?? ?http, server, location
This directive appeared in version 1.7.8.

31.8?proxy_ssl_protocols?

Syntax:?? ?proxy_ssl_protocols [SSLv2] [SSLv3] [TLSv1] [TLSv1.1] [TLSv1.2] [TLSv1.3];
Default:?? ?proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
Context:?? ?http, server, location
This directive appeared in version 1.5.6.

31.9?proxy_ssl_server_name?

Syntax:?? ?proxy_ssl_server_name on | off;
Default:?? ?proxy_ssl_server_name off;
Context:?? ?http, server, location
This directive appeared in version 1.7.0.

31.10?proxy_ssl_session_reuse?

Syntax:?? ?proxy_ssl_session_reuse on | off;
Default:?? ?proxy_ssl_session_reuse on;
Context:?? ?http, server, location

31.11?proxy_ssl_trusted_certificate?

Syntax:?? ?proxy_ssl_trusted_certificate file;
Default:?? ?—
Context:?? ?http, server, location
This directive appeared in version 1.7.0.

31.12?proxy_ssl_verify?

Syntax:?? ?proxy_ssl_verify on | off;
Default:?? ?proxy_ssl_verify off;
Context:?? ?http, server, location
This directive appeared in version 1.7.0.

31.13?proxy_ssl_verify_depth?

Syntax:?? ?proxy_ssl_verify_depth number;
Default:?? ?proxy_ssl_verify_depth 1;
Context:?? ?http, server, location
This directive appeared in version 1.7.0.

32.?proxy_store?

Syntax:?? ?proxy_store on | off | string;
Default:?? ?proxy_store off;
Context:?? ?http, server, location

33.?proxy_store_access?

Syntax:?? ?proxy_store_access users:permissions ...;
Default:?? ?proxy_store_access user:rw;
Context:?? ?http, server, location

34.?proxy_temp_file_write_size?

Syntax:?? ?proxy_temp_file_write_size size;
Default:?? ?proxy_temp_file_write_size 8k|16k;
Context:?? ?http, server, location

35.?proxy_temp_path?

Syntax:?? ?proxy_temp_path path [level1 [level2 [level3]]];
Default:?? ?proxy_temp_path proxy_temp;
Context:?? ?http, server, location

文章来源:https://blog.csdn.net/ShenDaiSun/article/details/135281090
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。