Home > Blockchain >  Can't connect to magento remotely
Can't connect to magento remotely

Time:09-29

I am trying to deploy a Magento 2 server with a bitnami docker container in an ec2 and it does not give me a response when connecting outside the server.

when i use curl with localhost:80 it gives me the expected html, but when I do it from my computer I only get this:

curl -v (server.ip):80
*   Trying (server.ip):80...
* Connected to (server.ip) ((server.ip)) port 80 (#0)
> GET / HTTP/1.1
> Host: (server.ip)
> User-Agent: curl/7.85.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 302 Found
< Date: Wed, 28 Sep 2022 21:57:22 GMT
< Server: Apache
< Set-Cookie:
PHPSESSID=lbnqf9tmm5pc7fpu7v2dm28lct;expires=Wed, 28-Sep-2022 22:57:22 GMT; Max-Age=3600; path=/; domain=(server.ip); HttpOnly; SameSite=Lax
< Expires: Tue, 28 Sep 2021 21:57:22 GMT
< Cache-Control: max-age=0, must-revalidate, no-cache, no-store
< Pragma: 
< Location: http://localhost/
< Content-Security-Policy-Report-Only: font-src data: 'self' 'unsafe-inline'; form-action <cut this because it tells me it looks like spam>
< X-Content-Type-Options: nosniff
< X-XSS-Protection: 1; mode=block
< X-Frame-Options: SAMEORIGIN
< X-UA-Compatible: IE=edge
< Content-Length: 0
< Content-Type: text/html; charset=UTF-8
<
* Connection #0 to host (server.ip) left intact

after this there should be the html.

I try a server in node with port 80 and it went correctly and the security group are fine, so I don't know what could be going on.

The server is a ubuntu 22.04 lts with t2.micro and I added 4gb of swap memory.

I use docker compose with this yaml for the installation:

version: '2'
services:
  mariadb:
    image: docker.io/bitnami/mariadb:10.4
    environment:
# ALLOW_EMPTY_PASSWORD is recommended only for development.
- ALLOW_EMPTY_PASSWORD=yes
- MARIADB_USER=bn_magento
- MARIADB_DATABASE=bitnami_magento
volumes:                                                                                  - '/etc/bitnami/mariadb:/bitnami/mariadb'
  magento:
    image: docker.io/bitnami/magento:2
    ports:
      - '80:8080'
      - '443:8443'
    environment:
      - MAGENTO_HOST=localhost
      - MAGENTO_DATABASE_HOST=mariadb
      - MAGENTO_DATABASE_PORT_NUMBER=3306
      - MAGENTO_DATABASE_NAME=bitnami_magento
      - MAGENTO_DATABASE_USER=bn_magento
      - MAGENTO_SEARCH_ENGINE=elasticsearch6
      - ELASTICSEARCH_HOST=elasticsearch
      - ELASTICSEARCH_PORT_NUMBER=9200
      # ALLOW_EMPTY_PASSWORD is recommended only for development.
      - ALLOW_EMPTY_PASSWORD=yes
      - MAGENTO_USERNAME=username
      - MAGENTO_PASSWORD=pass
      - [email protected]
      - MAGENTO_FIRST_NAME=firstname
      - MAGENTO_LAST_NAME=lastname
      - MAGENTO_ADMIN_URL_PREFIX=admin
      - MAGENTO_ENABLE_HTTPS=no
      - MAGENTO_ENABLE_ADMIN_HTTPS=no
    volumes:
      - '/etc/bitnami/magento:/bitnami/magento'
    depends_on:
      - mariadb
      - elasticsearch
  elasticsearch:
    image: docker.io/bitnami/elasticsearch:6
    volumes:
      - '/etc/bitnami/elasticsearch:/bitnami/elasticsearch'
    environment:
      - ELASTICSEARCH_HEAP_SIZE=512m
volumes:
  mariadb_data:
    driver: local
  magento_data:
    driver: local
  elasticsearch_data:
    driver: local

And these are the logs of magento: sudo docker logs magento

CodePudding user response:

That Location: http://localhost/ is suspicious. Maybe you should change the MAGENTO_HOST=localhost parameter to your aws public IP (or some hostname). Try curl -H 'Host: localhost' http://<server-ip> -v

  • Related