nginx.confhttp块中增加include conf.d/*.conf如下。

/usr/locol/nginx/conf/nginx.conf
1
2
3
http {
include conf.d/*.conf;
}

www.example.com为例,在conf.d文件夹下创建www.example.com.conf文件,根据需要增加如下配置块。

/usr/locol/nginx/conf/conf.d/www.example.com.conf
1
2
3
4
5
server {
listen 80;
server_name example.com www.example.com;
return 302 https://$host$request_uri;
}
/usr/locol/nginx/conf/conf.d/www.example.com.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
server {
listen 443 ssl;
server_name example.com www.example.com;
client_max_body_size 1024M;

ssl_certificate /root/.iaon/ssl/www.example.com.crt;
ssl_certificate_key /root/.iaon/ssl/www.example.com.key;

ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;

ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;

return 302 https://www.example.com$request_uri;
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
/usr/locol/nginx/conf/conf.d/www.example.com.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
server {
listen 443 ssl;
server_name www.example.com;
ssl_certificate /root/.iaon/ssl/www.example.com.crt;
ssl_certificate_key /root/.iaon/ssl/www.example.com.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
client_max_body_size 1024M;
location / {
proxy_redirect off;
proxy_set_header Host $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 https;
add_header Content-Security-Policy upgrade-insecure-requests;
proxy_pass http://127.0.0.1:10080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}