首先新建vhosts
文件夹于任意位置(当然最好有条理些)
修改配置文件
1
| vi /etc/nginx/nginx.conf
|
在配置文件server上面写入
1
| include /你的路径/vhosts/*.conf
|
进入新建的vhosts
文件夹,新建具有辨识性得名字.conf
编辑具有辨识性得名字.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
| server { listen 80; listen 443 ssl http2; server_name exp.net blog.exp.net; index index.html index.htm default.htm default.html; root /列示路径/; if ($server_port !~ 443){ rewrite ^(/.*)$ https://$host$1 permanent; } ssl_certificate /列示路径; ssl_certificate_key /列示路径; ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE; ssl_prefer_server_ciphers on; ssl_session_cache shared:SSL:10m; ssl_session_timeout 10m; error_page 497 https://$host$request_uri;
location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md) { return 404; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; error_log off; access_log /dev/null; } location ~ .*\.(js|css)?$ { expires 12h; error_log off; access_log /dev/null; } access_log /列示路径/access.log; error_log /列示路径/error.log; }
|
:wq
后,重载nginx配置文件