deny IP;
deny subnet;
deny all;
allow IP;
allow subnet;
allow all;
起因
## 访问/good.html?id=111 跳转到 /good/111
## 第一版
rewrite ^good.html\?(\d+)$ /good/$1 redirect
## 不生效
vim test.conf
[ req ]
default_bits = 2048 # RSA的2048是公认较比较安全的key长度
default_keyfile = server-key.pem
distinguished_name = subject
req_extensions = req_ext
x509_extensions = x509_ext
string_mask = utf8only
[ subject ]
countryName = Country Name (2 letter code)
countryName_default = US
stateOrProvinceName = State or Province Name (full name)
stateOrProvinceName_default = NY
localityName = Locality Name (eg, city)
localityName_default = New York
organizationName = Organization Name (eg, company)
organizationName_default = Example, LLC
commonName = Common Name (e.g. server FQDN or YOUR name)
commonName_default = Example Company
emailAddress = Email Address
emailAddress_default = test@example.com
[ x509_ext ]
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid,issuer
basicConstraints = CA:FALSE
keyUsage = digitalSignature, keyEncipherment
subjectAltName = @alternate_names
nsComment = "OpenSSL Generated Certificate"
[ req_ext ]
subjectKeyIdentifier = hash
basicConstraints = CA:FALSE
keyUsage = digitalSignature, keyEncipherment
subjectAltName = @alternate_names
nsComment = "OpenSSL Generated Certificate"
[ alternate_names ]
DNS.1 = *.test.com # 本地开发域名,支持正则
location / {
# 允许跨域
add_header Access-Control-Allow-Origin *;
# 允许的请求方法
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
# 允许的请求头
add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';
# 可在客户端被读取的返回头
Access-Control-Expose-Headers:'User-Token'
# 一般前端框架会在接口请求前走一遍 options 方法,默认都返回 204
# 204 (No Content)响应
# 205 在接受了浏览器POST请求以后处理成功以后, 告诉浏览器, 执行成功了, 请清空用户填写的Form表单, 方便用户再次填写,
if ($request_method = 'OPTIONS') {
return 204;
}
}