-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsample.com.conf
More file actions
93 lines (77 loc) · 2.65 KB
/
sample.com.conf
File metadata and controls
93 lines (77 loc) · 2.65 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#Nginx config used for solana RPC node
# Tune timeouts for proxy
proxy_buffering off;
proxy_connect_timeout 360s;
proxy_send_timeout 360s;
proxy_read_timeout 700s;
proxy_next_upstream error timeout http_500 http_502 http_503 http_504;
proxy_next_upstream_timeout 200s;
proxy_next_upstream_tries 5;
# Sets $conection_upgrade to 'close' if $http_upgrade is empty (empty), otherwise it is set to 'upgrade'
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
# Upstream solana RPC node websocket port
# changed to 30s timeout
upstream solana-proxy-ws {
server 0.0.0.0:8900 weight=3 max_conns=250 max_fails=1000000 fail_timeout=30s;
}
# Upstream solana RPC node http port
# changed to 30s timeout
upstream solana-proxy-http {
server 0.0.0.0:8899 weight=3 max_conns=250 max_fails=1000000 fail_timeout=30s;
}
server {
# Listen 443
listen 443 ssl;
# Set domain
server_name sample.com
# Disable favicon and robots error messages
location ~ ^/(favicon.ico|robots.txt) {
log_not_found off;
}
location /websocket/ {
# internal location only can access by rewrite, if client opens /websocket/ will return 404
internal;
# Direct to websocket location and set proxy headers
proxy_pass http://solana-proxy-ws;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
# Conditionally routes connection to websocket or http location based on value of http_connection or http_upgrade
location / {
# Sets $websocket to true if $http_connection ~=* "upgrade" or $http_upgrade !~* "websocket"
set $websocket 1;
if ($http_connection !~* "upgrade") {
set $websocket 0;
}
if ($http_upgrade !~* "websocket") {
set $websocket 0;
}
# if $websocket is true then append location
if ($websocket) {
rewrite ^ /websocket$uri last;
}
proxy_pass http://solana-proxy-http;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_intercept_errors on;
proxy_read_timeout 60s;
proxy_send_timeout 60s;
}
ssl_certificate /etc/letsencrypt/live/sample.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/sample.com/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
}
server {
if ($host = sample.com) {
return 301 https://$host$request_uri;
}
server_name sample.com;
listen 80;
return 404;
}