-
Notifications
You must be signed in to change notification settings - Fork 415
/
2_nginx.conf
43 lines (37 loc) · 1.89 KB
/
2_nginx.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#在‘http{}’里面添加(或修改)如下两个‘server’配置:
http {
#.........<省略>........
server {
listen 80; #IPv4,http默认监听端口。
listen [::]:80; #IPv6,http默认监听端口。无IPv6,此项可以删除。
return 301 https://$host$request_uri; #http自动跳转https,让网站看起来更真实。
}
server {
listen 443 ssl; #IPv4,https默认监听端口。
listen [::]:443 ssl; #IPv6,https默认监听端口。无IPv6,此项可以删除。
server_name xx.yy; #更改为自己的域名
if ($host ~ "\d+\.\d+\.\d+\.\d") { #禁止以ip方式访问网站
return 404;
}
ssl_certificate /home/tls/xx.yy/xx.yy.crt; #换成自己的证书,绝对路径。
ssl_certificate_key /home/tls/xx.yy/xx.yy.key; #换成自己的密钥,绝对路径。
ssl_protocols TLSv1.2 TLSv1.3; #TLSv1.3可能需要源码编译才支持,见此部分README.md说明。
ssl_ciphers ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-ECDSA-CHACHA20-POLY1305;
ssl_prefer_server_ciphers on;
location = /HALdGZ9k { #与vless+ws或vmess+ws应用中path对应
proxy_redirect off;
proxy_pass unix:/dev/shm/vws.sock; #转发给本机vless+ws或vmess+ws监听进程
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; #启用HSTS
location / {
root /var/www/html/; #更改为自己存放的web文件路径
index index.html index.htm;
}
}
}