2019-05-30 01:18:15 +00:00
|
|
|
|
#
|
|
|
|
|
# 提供 www 目录的静态资源服务
|
|
|
|
|
#
|
|
|
|
|
include mime.types;
|
|
|
|
|
sendfile on;
|
|
|
|
|
charset utf-8;
|
|
|
|
|
|
2019-06-11 08:38:47 +00:00
|
|
|
|
# 安装步骤多,节省的流量不多,暂时不开
|
2019-05-30 01:18:15 +00:00
|
|
|
|
# brotli_static on;
|
|
|
|
|
# gzip_static on;
|
|
|
|
|
gzip on;
|
|
|
|
|
|
|
|
|
|
log_not_found off;
|
|
|
|
|
error_page 404 = /404.html;
|
|
|
|
|
|
|
|
|
|
location = /404.html {
|
|
|
|
|
internal;
|
|
|
|
|
root ../www;
|
|
|
|
|
|
2019-07-10 07:18:21 +00:00
|
|
|
|
# http 重定向到 https(忽略 localhost 或 IP 访问)
|
|
|
|
|
access_by_lua_block {
|
|
|
|
|
if ngx.var.scheme == 'https' then
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
local host = ngx.var.host
|
|
|
|
|
if host == 'localhost' then
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
if ngx.re.match(host, [[^\d+\.\d+\.\d+\.\d+$]]) then
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
local url = host .. ':8443' .. ngx.var.request_uri
|
|
|
|
|
ngx.redirect('https://' .. url, 301)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# 永久重定向申请: https://hstspreload.org/
|
|
|
|
|
more_set_headers
|
|
|
|
|
'strict-transport-security: max-age=99999999; includeSubDomains; preload'
|
|
|
|
|
;
|
2019-06-20 08:07:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-05-30 01:18:15 +00:00
|
|
|
|
location / {
|
|
|
|
|
access_log logs/access.log log_www buffer=64k flush=1s;
|
|
|
|
|
root ../www;
|
2019-07-10 07:18:21 +00:00
|
|
|
|
index 404.html;
|
2019-05-30 01:18:15 +00:00
|
|
|
|
}
|
2019-07-10 11:51:44 +00:00
|
|
|
|
|
|
|
|
|
# HTTPS 证书申请验证
|
|
|
|
|
location /.well-known/acme-challenge/ {
|
2019-07-10 13:34:00 +00:00
|
|
|
|
access_log logs/acme.log combined;
|
2019-07-10 11:51:44 +00:00
|
|
|
|
root ../acme;
|
|
|
|
|
}
|