The IP of my domain does not redirect to my domain

Hello, first I wanted to congratulate this wonderful project that I magically found on the internet trying to put an ssl certificate to my server.

My problem:
I am using a docker-compose that I found in an internet post to integrate grafana, influxdb with an ssl certificate and it is the following:

version: "3"

services:
  grafana:
    labels:
      # SSL redirect requires a separate router (https://github.com/containous/traefik/issues/4688#issuecomment-477800500)
      - "traefik.http.routers.some-name.entryPoints=port80"
      - "traefik.http.routers.some-name.rule=host(`midomain.com.ar`,`misubdomain.midomain.com.ar`)"
      - "traefik.http.middlewares.some-name-redirect.redirectScheme.scheme=https"
      - "traefik.http.middlewares.some-name-redirect.redirectScheme.permanent=true"
      - "traefik.http.routers.some-name.middlewares=some-name-redirect"
      # SSL endpoint
      - "traefik.http.routers.some-name-ssl.entryPoints=port443"
      - "traefik.http.routers.some-name-ssl.rule=host(`midomain.com.ar`,`misubdomain.midomain.com.ar`)"
      - "traefik.http.routers.some-name-ssl.tls=true"
      - "traefik.http.routers.some-name-ssl.tls.certResolver=le-ssl"
      - "traefik.http.routers.some-name-ssl.service=some-name-ssl"
      - "traefik.http.services.some-name-ssl.loadBalancer.server.port=3000"
    image: grafana/grafana:latest # or probably any other version
    volumes:
      - grafana-data:/var/lib/grafana
    environment:
      - GF_SERVER_ROOT_URL=https://midomain.com.ar
      - GF_SERVER_DOMAIN=midomain.com.ar
      - GF_USERS_ALLOW_SIGN_UP=false
      - GF_SECURITY_ADMIN_USER=admin
      - GF_SECURITY_ADMIN_PASSWORD=adminn

  influx:
    image: influxdb:latest # or any other recent version
    labels:
      # SSL endpoint
      - "traefik.http.routers.some-name-influx-ssl.entryPoints=port8086"
      - "traefik.http.routers.some-name-influx-ssl.rule=host(`midomain.com.ar`)"
      - "traefik.http.routers.some-name-influx-ssl.tls=true"
      - "traefik.http.routers.some-name-influx-ssl.tls.certResolver=le-ssl"
      - "traefik.http.routers.some-name-influx-ssl.service=some-name-influx-ssl"
      - "traefik.http.services.some-name-influx-ssl.loadBalancer.server.port=8086"
    restart: always
    volumes:
      - influx-data:/var/lib/influxdb
    environment:
      - INFLUXDB_DB=OPC_DB # set any other to create database on initialization
      - INFLUXDB_HTTP_ENABLED=true
      - INFLUXDB_HTTP_AUTH_ENABLED=true

      - INFLUXDB_ADMIN_USER=ADMIN 
      - INFLUXDB_ADMIN_PASSWORD=ADMINN

  traefik:
    image: traefik:latest
    ports:
      - "80:80"
      - "443:443"
      - "8086:8086"
      - "8080:8080"
    command:
      - "--log.level=DEBUG"
      - "--api=true"
      - "--providers.docker=true"

      - "--entryPoints.port443.address=:443"
      - "--entryPoints.port80.address=:80"
      - "--entryPoints.port8086.address=:8086"
      - "--certificatesResolvers.le-ssl.acme.tlsChallenge=true"
      - "--certificatesResolvers.le-ssl.acme.email=miemail@midomain.com.ar"
      - "--certificatesResolvers.le-ssl.acme.storage=/letsencrypt/acme.json"
    volumes:
      - traefik-data:/letsencrypt/
      - /var/run/docker.sock:/var/run/docker.sock

volumes:
  traefik-data:
  grafana-data:
  influx-data:

It works perfect, if I enter through http://midomain.com it redirects it to port 443. But when entering directly through the ip (http://xxx.xxx.xxx.xxx) of my domain it returns an error 404 not found, really I am very new and I know that I am missing some configuration but I cannot understand where I may be failing, I would appreciate any help. And forgive my writing or if this has already been asked, I am not very good with English.

Welcome to the forum @nexun

All your rules are using Host() and TLS. Your requests must include the servername in the TLS handshake.

The rule that is on port 80 and not TLS enabled is also a Host() rule so must include a Host header or the rule will not match.

If the domain resolves, why are you trying this with IP address only?

I am looking for the same thing, when someone tries to access the ip through the browser to redirect to the domain. I don't know if that is possible

Use a PathPrefix(`/`) with a very low (1) priority with a redirectRegex middleware.

2 Likes

Thank you I will check and try.