首页 > 解决方案 > 使用 docker 时在 magento2 中使用什么作为基本 url?

问题描述

我有简单的 docker 编排来提供 Magento 文件,这里是我的 docker-compose.yml:

version: "3"

services:
    php:
        build: docker/php
        volumes:
            - .:/var/www/html

    db:
        image: mariadb:10.4
        ports:
            - 3306:3306
        environment:
            MYSQL_ROOT_PASSWORD: password
            MYSQL_DATABASE: magento
        volumes:
            - ./docker/mysql/databases:/var/lib/mysql

    nginx:
        image: nginx:alpine
        ports:
            - 8009:80
        links:
            - php:phpfpm
        volumes:
            - ./docker/nginx/conf.d:/etc/nginx/conf.d
            - ./docker/nginx/magento.conf:/etc/nginx/magento.conf
            - .:/var/www/html

    elasticsearch:
        image: bitnami/elasticsearch:7
        ports:
            - 9200:9200
        volumes:
            - ./docker/elasticsearch/data:/bitnami/elasticsearch/data

如您所见,我想在我的主机端口 8009 上为商店提供服务。

我的问题是,在使用 setup:install 命令并安装我的 Magento 商店时,我应该设置什么 base-url?如果我将其设置为类似 localhost 或 127.0.0.1,当访问 localhost:8009 时,它会将我重定向到 127.0.0.1,这显然是错误的位置

标签: dockernginxmagentomagento2

解决方案


当您在 docker 中使用客户端口时,您希望使用的基本 URL 是 URL:端口。

示例 =>

base_url=https://localhost:8009/


推荐阅读