forked from lxhao61/integrated-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
1_nginx.conf
72 lines (57 loc) · 2.75 KB
/
1_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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#user nobody nogroup; #表示以默认用户(root)运行。若取消注释,注意修改为相应权限的用户与组。
worker_processes auto;
error_log /var/log/nginx/error.log; #错误日志的文件地址
pid /run/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main; #访问日志的文件地址
sendfile on;
keepalive_timeout 65;
server {
listen 80;
listen [::]:80; #无 IPv6,此项可删除。
return 301 https://$host$request_uri; #HTTP 自动跳转 HTTPS,让网站看起来更真实。
}
server {
listen 127.0.0.1:82 http2 proxy_protocol; #使用 H2C server 本地监听端口,且开启 PROXY protocol 接收。(仅版本小于 v1.25.1 配置,否则必须删除。)
listen 127.0.0.1:88 proxy_protocol; #使用 H2C server 及 HTTP/1.1 server 本地监听端口,且开启 PROXY protocol 接收。(仅版本不小于 v1.25.1 配置,否则必须删除。)
http2 on; #仅版本不小于 v1.25.1 配置,否则必须删除。
set_real_ip_from 127.0.0.1;
real_ip_header X-Forwarded-For;
location /SALdGZ9k { #与 Shadowsocks+gRPC 应用中 serviceName 对应
if ($request_method != "POST") {
return 404;
} #POST 协商失败时返回 404
client_body_buffer_size 1m;
client_body_timeout 1h;
client_max_body_size 0;
grpc_pass grpc:https://127.0.0.1:2011; #转发给本机 Shadowsocks+gRPC 监听端口
grpc_read_timeout 1h;
grpc_send_timeout 1h;
grpc_set_header Host $host;
grpc_set_header X-Real-IP $remote_addr;
}
location / {
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; #启用 HSTS
root /var/www/html; #修改为自己存放的 WEB 文件路径
index index.html index.htm;
}
}
server {
listen 127.0.0.1:81 proxy_protocol; #使用 HTTP/1.1 server 本地监听端口,且开启 PROXY protocol 接收。
set_real_ip_from 127.0.0.1;
real_ip_header proxy_protocol;
location / {
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; #启用 HSTS
root /var/www/html; #修改为自己存放的 WEB 文件路径
index index.html index.htm;
}
} #仅版本小于 v1.25.1 配置,否则必须删除。
}