/
map.bash
executable file
·47 lines (39 loc) · 1.03 KB
/
map.bash
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
#!/bin/bash
root="$HOME/x.x"
name="$1"
port="$2"
>"$root/$name.nginx" cat <<nginxconf
server {
default_type text/plain;
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name $name.x.x;
ssl_certificate $root/x.x.crt;
ssl_certificate_key $root/x.x.key;
location / {
proxy_pass http://127.0.0.1:$port/;
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;
proxy_set_header X-Forwarded-Proto \$scheme;
client_max_body_size 100m;
}
}
server {
default_type text/plain;
listen 80;
listen [::]:80;
server_name $name.x.x;
location / {
proxy_pass http://127.0.0.1:$port/;
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;
proxy_set_header X-Forwarded-Proto \$scheme;
client_max_body_size 100m;
}
}
nginxconf
sudo nginx -s reload
open "https://$name.x.x"
# ln -s "$root/$name.nginx" "$root/port"