[Nginx] HTTP to HTTPS – 80 to 443 – 自動轉導

設定檔

這裡拿一個非Default的Site Host作範例。

添加80port的設定檔範例:

server {
        listen 80;
        listen [::]:80;
        server_name code.yidas.com;
        return 301 https://$server_name$request_uri;
}

至於原來的設定檔則由80改至443:

#listen 80;
#listen [::]:80;

# SSL configuration
#
listen 443 ssl;
listen [::]:443 ssl;

Leave a Reply

Your email address will not be published. Required fields are marked *