nginx http、 https十拣、 http2配置
nginx版本:1.12.2
// 首先找到nginx.conf
// 查看nginx.conf 路徑
nginx -t
*注:以下配置重啟才能生效
http配置
1封拧、配置域名
// 比如配置成baidu.com
http {
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name baidu.com; <<<<<<<<<
}
}
2、域名的訪問(wèn)地址
http {
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name baidu.com; // 域名
root /server/www/ // 訪問(wèn)baidu.com 所訪問(wèn)的服務(wù)器路徑
}
}
http2 & https
- 配置域名和訪問(wèn)的路徑與http完全相同夭问,區(qū)別在于證書(shū)
- 查看443端口是否打開(kāi)
1.找個(gè)個(gè)證書(shū)
2.修改nginx.conf 文件
server {
listen 443 ssl http2 default_server;
listen [::]:443 ssl http2 default_server;
server_name m.xxx.com;
root /service;
ssl_certificate "/etc/nginx/cert/214744744310771.pem"; // 證書(shū)目錄
ssl_certificate_key "/etc/nginx/cert/214744744310771.key"; // 證明目錄
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
3.查看結(jié)果
瀏覽器查看 https://m.xxx.com