HTTPS、重定向、静态文件、分流

HTTPS

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
upstream halo {
server 127.0.0.1:8090;
}
server {
listen 443 ssl;
server_name chengs.run;
ssl_certificate cert/chengs.run.crt;
ssl_certificate_key cert/chengs.run.key;
client_max_body_size 1024m;
location / {
proxy_pass http://halo;
proxy_set_header HOST $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}

重定向

1
2
3
4
5
server {
listen 80;
server_name *.chengs.run chengs.run;
return 301 https://$host$request_uri;
}

静态文件

1
2
3
4
5
6
7
8
9
server{
listen 443 ssl;
server_name note.chengs.run;
ssl_certificate cert/note.chengs.run.crt;
ssl_certificate_key cert/note.chengs.run.key;

root /www/notes;
index index.html;
}

分流

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
server{
listen 443 ssl;
server_name api.chengs.run;
ssl_certificate cert/api.chengs.run.crt;
ssl_certificate_key cert/api.chengs.run.key;

location /daxuexi {
proxy_pass http://127.0.0.1:8000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
}
location /botmessage/ {
proxy_pass http://127.0.0.1:5700/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
}
}

普通

1
2
3
4
5
6
7
8
9
10
11
server{
listen 80;
server_name jd.chengs.run;
location / {
proxy_pass http://azure.opaw.tk:5700;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
}
}