设置DNS解析

设置A记录分别设置www和@,在阿里云里,主机记录不填或者填@是一个效果。
在这里插入图片描述

nginx配置

主要的设置是:

server_name xxx.com www.xxx.com;

以下代码案例是同时支持https和http的情况,这边主要是server_name 要配置两个。其他重写配置,好像不是必须的

server {
    listen 80;
    server_name xxx.com www.xxx.com;
    rewrite  ^/(.*)$  https://www.xxx.com/$1 permanent;
}

server {
    listen 443 ssl;
    server_name xxx.com www.xxx.com;

    ssl_prefer_server_ciphers on;
    ssl_ciphers HIGH:!ADH:!MD5:!aNULL:!eNULL:!MEDIUM:!LOW:!EXP:!kEDH;
    ssl_protocols TLSv1.2 TLSv1.1 TLSv1;
    ssl_session_timeout 1d;
    ssl_session_cache shared:SSL:50m;
    ssl_stapling on;
    ssl_stapling_verify on;
    add_header Strict-Transport-Security max-age=15768000;

    ssl_certificate /etc/letsencrypt/live/www.xxx.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/www.xxx.com/privkey.pem;


    location / {
        try_files $uri $uri/ /index.html;
        root /opt/xxx/xxx;
        index index.html index.htm;
    }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
                root   html;
        }
}
最后修改:2025 年 03 月 23 日
如果觉得我的文章对你有用,请随意赞赏