--- 2020-07-09笔记 ---
壹、HTTP 301 跳转至 HTTPS
server {
listen 80;
server_name xxx.com;
return 301 https://$server_name$request_uri;
}
贰、HTTPS证书配置
server {
listen 443 ssl;
server_name xxx.com;
ssl_certificate /data/xx.com.crt;
ssl_certificate_key /data/xx.com.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
location / {
root /data/rongxinservice/sources;
index index.html index.htm;
# 开启目录列表
autoindex on;
}
}
叁、开启目录列表
location / {
# 开启目录列表
autoindex on;
root /data/sources;
index index.html index.htm;
}
肆、反代虚拟二级目录
例如:
http(s)://a.com:8080/ --> http(s)://b.com/a/
http(s)://a.com:8080/test/ --> http(s)://b.com/test/
http(s)://127.0.0.1:8080/ --> http(s)://b.com
....
-- 方法壹:记得在目录后加上"/"
location /test/ {
proxy_pass https://xxx.com/;
}
-- 方法贰:使用rewrite(未检验)
location / {
rewrite /test/(.*) /$1 break;
proxy_pass http://127.0.0.1;
}