FAQ

Page Discussion Edit History

ChsHttpAccessKeyModule

Contents

[edit] Synopsis 鎬昏堪

This module is not distributed with the Nginx source. See the installation instructions.

姝ゆā鍧楁病鏈夎鍖呭惈鍦∟ginx瀹樻柟瀹夎鍖呬腑. 璇风湅 瀹夎浠嬬粛.

This module denies access unless the request URL contains an access key. Keys can correspond to remote IP addresses or other variables, so that downloads may be dynamically restricted to certain clients.

杩欎釜妯″潡鍙互闃绘鎵鏈塙RL涓湭鍖呭惈鍚堟硶璁块棶浠ょ墝鐨勮闂紙闃茬洍閾撅級銆傝闂护鐗屽彲浠ョ敱璁块棶鑰匢P鎴栬呭叾瀹冩湇鍔″櫒鍙橀噺鐢熸垚锛屾墍浠ュ彲浠ュ緢濂藉湴鎺у埗瀹㈡埛绔殑涓嬭浇琛屼负銆

Example configuration: 閰嶇疆瀹炰緥锛

location /download {
  accesskey             on;
  accesskey_hashmethod  md5;
  accesskey_arg         "key";
  accesskey_signature   "mypass$remote_addr";
}

A client might then be directed to, e.g., http://example.com/download/file.zip?key=09093abeac094.

鐢ㄦ埛寰楀埌鐨勪笅杞藉湴鍧鍙兘鍍忚繖鏍凤細 http://example.com/download/file.zip?key=09093abeac094銆

[edit] Directives 鎸囦护

[edit] accesskey

syntax: accesskey [on|off]

璇彞: accesskey [on|off]

default: accesskey off

榛樿: accesskey off

context: main, server, location

鍙互鐢ㄥ湪: main, server, location

Enables access-key restrictions.

寮鍚 access-key 鍔熻兘銆

[edit] accesskey_arg

syntax: accesskey_arg "string"

璇彞: accesskey_arg "瀛楃"

default: accesskey "key"

榛樿: accesskey "key"

context: main, server, location

鍙互鐢ㄥ湪: main, server, location

The URL that contains the access key.

URL涓寘鍚 access key 鐨凣ET鍙傛暟銆

[edit] accesskey_hashmethod

syntax: accesskey_hashmethod [md5|sha1]

璇彞: accesskey_hashmethod [md5|sha1]

default: accesskey_hashmethod md5

榛樿: accesskey_hashmethod md5锛堥粯璁ょ敤 md5 鍔犲瘑锛

context: main, server, location

鍙互鐢ㄥ湪: main, server, location

Whether to use MD5 or SHA-1 for key creation.

鐢 MD5 杩樻槸 SHA1 鍔犲瘑 access key銆

[edit] accesskey_signature

syntax: accesskey_signature "string"

璇彞: accesskey_signature "瀛楃"

default: accesskey_signature "$remote_addr"

榛樿: accesskey_signature "$remote_addr"

context: main, server, location

鍙敤鍦: main, server, location

The string to hash to create an access key. Include the $remote_addr variable to make keys unique to client IP addresses. Be sure to include a secret phrase as well to protect the integrity of your keys. (E.g. "myPassWord$remote_addr".)

杩欎釜鍊肩敤鏉ョ敓鎴 access key銆傦紙鎹㈠彞璇濊灏辨槸浼氱敤MD5鎴栬匰HA1鍔犲瘑杩欎釜鍊硷級銆傚姞鍏$remote_addr鐨勫師鍥犳槸璁 access key 涓庣壒瀹氱殑鏈哄櫒鑱旂郴锛堥氳繃IP鍦板潃锛夈傝娉ㄦ剰鍔犲叆浣犺嚜宸辩殑瀵嗘枃鏉ヤ繚鎶 acccess key锛岄槻姝㈣浜虹牬瑙c傦紙渚嬪"myPassword$remote_addr"銆傦級

[edit] Installation 瀹夎

Download the module source here: File:Nginx-accesskey-2.0.3.tar.gz

鍏堝湪杩欓噷涓嬭浇妯″潡婧愮爜: File:Nginx-accesskey-2.0.3.tar.gz

Unpack, edit the "config" file, replace "$HTTP_ACCESSKEY_MODULE" with "ngx_http_accesskey_module", and then compile nginx with:

瑙e帇锛岀劧鍚庣紪杈 "config" 鏂囦欢锛屽皢 "$HTTP_ACCESSKEY_MODULE""ngx_http_accesskey_module" 鏇挎崲銆傜劧鍚庣紪璇戯細

 ./configure --add-module=path/to/nginx-accesskey

[edit] Credits 寮鍙戜汉鍛

Originally developed for OWOX project

鏈鍒濇槸涓轰簡杩欎釜缃戠珯寮鍙戠殑锛 OWOX 椤圭洰

[edit] Translation 缈昏瘧

Translationed by Dndx On Dec,5,2009.

鐢 Dndx 鍦 2009骞12鏈5鏃 缈昏瘧銆