-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtemplate.nginx.conf
119 lines (92 loc) · 3.21 KB
/
template.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# user www-data;
# user root;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
# # 定义 Nginx 负载均衡器配置
upstream backend {
server 120.24.5.14:1024; # 特权用户一般可以绑定低于 1024 的端口,而非特权用户应该使用大于或等于 1024 的端口
}
# https配置 默认跳转
server {
listen 443 ssl;
server_name lp.wszhu.top; # 服务器地址、域名
ssl_certificate /var/www/cert/lp.wszhu.top.pem;
ssl_certificate_key /var/www/cert/lp.wszhu.top.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # 可选,指定所支持的SSL/TLS协议版本
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_prefer_server_ciphers on; # 可选,启用服务器端密码优先
location / {
root /var/www/learn-platform/pc;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
error_page 404 /404.html;
location = /404.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
# 网页端
server{
listen 80; # 网页端端口
server_name lp.wszhu.top;
# 代理请求到后端服务器
location /graphql {
add_header Access-Control-Allow-Origin * always;
proxy_pass http://backend/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
return 301 https://$host$request_uri;
}
# 移动端
server {
listen 8080 ssl; # 移动端端口
server_name lp.wszhu.top; # 服务器地址、域名
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
ssl_certificate /var/www/cert/lp.wszhu.top.pem;
ssl_certificate_key /var/www/cert/lp.wszhu.top.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # 可选,指定所支持的SSL/TLS协议版本
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_prefer_server_ciphers on; # 可选,启用服务器端密码优先
location / {
root /var/www/learn-platform/mobile;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
# 代理请求到后端服务器
location /graphql {
add_header Access-Control-Allow-Origin * always;
proxy_pass http://backend/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
}