MDeLuise / plant-it

🪴 Self-hosted, open source gardening companion app
https://plant-it.org
GNU General Public License v3.0
455 stars 17 forks source link

Connection to server fails #154

Closed omegaMk13 closed 1 month ago

omegaMk13 commented 2 months ago

Avoid duplicated bug reports

Description

When accessing the frontend interface via web browser, plant-it asks for the server URL. Upon entering, it displays the error message: "Oops! Cannot connect to the server". Does anything else need to be installed for plant-it to work?

Local environment

v.0.5 compose file: version: "3" name: plant-it services: server: image: msdeluise/plant-it-server:latest env_file: server.env depends_on:

server.env: # MYSQL_HOST=db MYSQL_PORT=3306 MYSQL_USERNAME=root MYSQL_PSW=root MYSQL_DATABASE=bootdb MYSQL_ROOT_PASSWORD=root

#

JWT

# JWT_SECRET= JWT_EXP=1

#

Server config

# USERS_LIMIT=-1 UPLOAD_DIR=/upload-dir API_PORT=8080 TREFLE_KEY= LOG_LEVEL=DEBUG ALLOWED_ORIGINS=*

#

Cache

# CACHE_TTL=86400 CACHE_HOST=cache CACHE_PORT=6379

#

SSL

# SSL_ENABLED=false CERTIFICATE_PATH=/certificates/

MDeLuise commented 1 month ago

Hi @omegaMk13, thanks for opening the issue. Could you please share the docker-compose log of the deployment?

Did you insert http://<your_ip>:8009 as server URL in that screen?

Ploonet commented 1 month ago

I think I have the same problem, so i'm not sure if i should open a new issue.

The only differences I might have :

MDeLuise commented 1 month ago

Hi @Ploonet, I'm seeing that some users have problems with nginx/traefik, I plant to create a local dummy environment to inspect the behavior more closely.

In general, the URL you should insert in the server URL configuration is the same as the one used to access the Swagger UI console. So, if you're able to reach the Swagger UI, the application should theoretically be able to connect to the server.

Could you please confirm whether you're able to connect to Swagger at <url_you_try_to_use>:<port>/api/swagger-ui/index.html? The default port in the docker-compose file is 8080, but if you've changed the port binding, please use that value instead.

If everything works fine, you should see something like this

Screenshot 2024-05-08 at 16 02 20
Ploonet commented 1 month ago

Hi, thanks for the reply !

I did change the default port to 8081 in the docker compose (8081:8080) and server.env API_PORT=8081. And I had already tried accessing Swagger with https://<mydomain>:8081/api/swagger-ui/index.html, without success.. I don't see any particular error nor any log in the server container.

Here's my docker compose

version: "3"
name: plant-it
services:
  server:
    image: msdeluise/plant-it-server:latest
    env_file: server.env
    depends_on:
      - db
      - cache
    restart: unless-stopped
    volumes:
      - "./upload-dir:/upload-dir"
      - "./certs:/certificates"
    ports:
      - "8081:8080"
      - "3000:3000"

  db:
    image: mysql:8.0
    restart: always
    env_file: server.env
    volumes:
      - "./db:/var/lib/mysql"

  cache:
    image: redis:7.2.1
    restart: always

networks:
  default:
    name: "net"
    external: "true"

The networks part is used by the nginx-proxy and letsencrypt-helper.

And the env file

MYSQL_HOST=db
MYSQL_PORT=3306
MYSQL_USERNAME=root
MYSQL_PSW=root
MYSQL_DATABASE=bootdb
MYSQL_ROOT_PASSWORD=root

JWT_SECRET=<secret>
JWT_EXP=1

USERS_LIMIT=-1
UPLOAD_DIR=/upload-dir
API_PORT=8081
TREFLE_KEY=
LOG_LEVEL=DEBUG
ALLOWED_ORIGINS=*

CACHE_TTL=86400
CACHE_HOST=cache
CACHE_PORT=6379

SSL_ENABLED=yes
CERTIFICATE_PATH=/certificates/

#
# PROXY (these are variables used by the nginx-proxy and letsencrypt-helper)
#
VIRTUAL_HOST: "<host>"
VIRTUAL_PORT: "3000" 
LETSENCRYPT_HOST: "<host>"

Let me know if I can provide anything else to help you understand.

omegaMk13 commented 1 month ago

Hi @omegaMk13, thanks for opening the issue. Could you please share the docker-compose log of the deployment?

Did you insert http://<your_ip>:8009 as server URL in that screen?

Hi, yes I did. I wasn't sure if I was supposed to change 8080 to 8009 in the server.env file, too.

Here's the docker log. output.log

crstian19 commented 1 month ago

Here using traefik, I exposed API via URL with HTTPS and it doesn't work either. I don't quite understand why having SSL management inside the application itself, when practically everyone uses reverse proxies

omegaMk13 commented 1 month ago

Hi @omegaMk13, thanks for opening the issue. Could you please share the docker-compose log of the deployment? Did you insert http://<your_ip>:8009 as server URL in that screen?

Hi, yes I did. I wasn't sure if I was supposed to change 8080 to 8009 in the server.env file, too.

Here's the docker log. output.log

This seems to indeed have been the problem! I used the same port in the server.env file - it's quite obvious, actually, but I think this is missing in your working example in the installation guide.