配置了SSL 无法跳转到https

2.09K 浏览M2安装设置SSL

配置了SSL 无法跳转到https

按照教程配置了SSL 访问https://www.a.com正常打开 用http://www.a.com不能自动跳转到https

nginx.conf.sample 文件中也加入了以下代码

fastcgi_param MAGE_RUN_TYPE $MAGE_RUN_TYPE;
fastcgi_param MAGE_RUN_CODE $MAGE_RUN_CODE;
fastcgi_param MAGE_MODE $MAGE_MODE;

nginx和php 都重启过

upstream fastcgi_backend {
        server  unix:/run/php/php7.4-fpm.sock;
}
map $http_host $MAGE_RUN_CODE {
    www.a.com default;
    t.a.com cn
}
server {
        listen 80;
        server_name www.a.com a.com;
        set $MAGE_ROOT /var/www/magento2;
        set $MAGE_MODE developer;
        set $MAGE_RUN_TYPE store;
        include /var/www/magento2/nginx.conf.sample;
        error_log /var/log/magento2/nginx/error.log;
}

server {
        listen 80;
        server_name t.a.com;
        set $MAGE_ROOT /var/www/magento2;
        set $MAGE_MODE developer;
        set $MAGE_RUN_TYPE store;
        include /var/www/magento2/nginx.conf.sample;
        error_log /var/log/magento2/nginx/error.log;
}

server {
        listen 443 ssl http2;
        server_name www.a.com;
        set $MAGE_ROOT /var/www/magento2;
        set $MAGE_MODE developer;
        set $MAGE_RUN_TYPE store;
        include /var/www/magento2/nginx.conf.sample;
        error_log /var/log/magento2/nginx/error.log;
        ssl_certificate /etc/nginx/ssl/magento2/full_chain.pem; #change with your SSL cert
        ssl_certificate_key /etc/nginx/ssl/magento2/www.a.com_key.key; # change with your SSL key

}

server {
        listen 443 ssl http2;
        server_name t.a.com;
        set $MAGE_ROOT /var/www/magento2;
        set $MAGE_MODE developer;
        set $MAGE_RUN_TYPE store;
        include /var/www/magento2/nginx.conf.sample;
        error_log /var/log/magento2/nginx/error.log;
        ssl_certificate /etc/nginx/ssl/cn/full_chain.pem; #change with your SSL cert
        ssl_certificate_key /etc/nginx/ssl/cn/t.a.com_key.key; # change with your SSL key
}

已回答
0

server {
        listen 80;
        server_name www.a.com a.com;
        set $MAGE_ROOT /var/www/magento2;
        set $MAGE_MODE developer;
        set $MAGE_RUN_TYPE store;
        include /var/www/magento2/nginx.conf.sample;
        error_log /var/log/magento2/nginx/error.log;
}

改成

server { 
    listen 80; 
    server_name www.a.com a.com; 
    return 301 https://www.a.com$request_uri; 
}
编辑回答
0
您正在查看1个回答中的1个,单击此处查看所有回答。