-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgrpc-gw.conf
40 lines (33 loc) · 1.19 KB
/
grpc-gw.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
# go grpc http层nginx配置
# 多个实例负载均衡
upstream grpc_http {
server 127.0.0.1:1339 weight=80 max_fails=2 fail_timeout=10;
server 127.0.0.1:1340 weight=80 max_fails=2 fail_timeout=10;
}
# nginx配置
server {
listen 80;
# 根据实际情况设置
server_name myrpc.com www.myrpc.com *.myrpc.com;
# 访问日志设置
access_log /data/logs/mygrpc/go-rpc-access.log;
error_log /data/logs/mygrpc/go-rpc-error.log;
# error_page 404 /etc/nginx/html/40x.html;
# error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /etc/nginx/html;
}
location @gorpc {
proxy_redirect off;
proxy_set_header Host $host; #为反向设置原请求头
proxy_set_header X-Read-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-NginX-Proxy true;
proxy_set_header X-Request-Uri $request_uri;
proxy_set_header X-Referer $http_referer;
proxy_pass http://gorpc_http; #负载代理
}
location / {
try_files $uri @gorpc;
}
}