#HTTP配置 server { listen 80; listen [::]:80; server_name www.baidu.com; return 301 https://www.baidu.com; location / { root /usr/share/nginx/html/mypage; index index.html index.htm; } } #HTTPS配置 server { listen 443 ssl; listen [::]:443 ssl; server_name www.baidu.com; ssl_certificate /etc/nginx/cert/fullchain.cer; # pem文件的路径 ssl_certificate_key /etc/nginx/cert/cert.key; # key文件的路径 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; location / { root /usr/share/nginx/html/mypage; index index.html index.htm; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } }