Call back: 404 error page not found

Hi all I am new to the field of reverse proxy & load balancer I follow the installation guide of the documentation
my config.toml:

[accesslog]
[api]
    insecure = true
    dashboard = true
    debug = true
[log]
    level = "INFO"

[entryPoints]
    [entryPoints.web]
        address = ":80"

    [entryPoints.nsia]
        address = "127.0.0.2:5000"
    [entryPoints.nsia.http]
    [entryPoints.nsia.http.redirections]
    [entryPoints.nsia.http.redirections.entryPoint]
        to = "websecure"
        scheme = "https"
        permanent = true
        priority = 10

    [entryPoints.websecure]
    address = ":443"

[providers.file]
    directory = "services/"
    watch = true

and this is my
traefik.toml file (is in service folder)

[http]
    [http.routers]
        [http.routers.traefik_route]
            entryPoints = ["nsia"]
            rule = "Host(`localhost`) && Path(`/api/*`)"
            middlewares = ["api-forwarding"]
            service = "traefik"

    [http.middlewares]
        [http.middlewares.api-forwarding.headers.customRequestHeaders]
            X-Forwarded-Host = "api.publicapis.org"
            X-Forwarded-Proto = "https"
            X-Forwarded-Port = "443"
            X-Forwarded-Uri = "/entries"


    [http.services]
        [http.services.traefik]
            [http.services.traefik.loadBalancer]
                [[http.services.traefik.loadBalancer.servers]]
                    url = "https://api.publicapis.org/entries"

But when I call "127.0.0.2:5000"
I get a 404 page not find error
Yet if I replace "https://api.publicapis.org/entries" by local adresse for exemple: "127.0.0.1:8001" server, it goes
Can anyone help me? It's very urgent!

Did you create 127.0.0.2 as IP on your host?

You have a redirect on your port 5000, so I would assume no requests on port 5000 will ever be forwarded.

Note that the forward headers are automatically created by Traefik.

Yes to do the test, I created an address: 127.0.0.2:5000, which I tested by pinging; The address successfully answers. My question is do I have to have a particular configuration.? The context of my project is as follows: Our team works in a local network (intranet) and we have to communicate with external partners. we cannot give direct access to our servers, So we want to make rediirection in order to communicate with the web services of the parties on the Internet without going through VPN.

i need help please

Can you provide more details? What is the URL you want to call and what is the URL Traefik should forward the request to? (What do they look like)

no problem, The address that Traefik must expose is: 127.10.126.123. The API I need to consume is: https://api.publicapis.org/entries (an example). So here, when I am on 127.10.126.123, it must automatically redirect me to https://api.publicapis.org/entries. and give me a result. The problem is that currently from I receive 404 page not found. whereas if I type directly www.edan.ci/api in my browser I get feedback.

to explain simply. Suppose I have a web service, I want to consume an API through Traefik. My server is: 17.10.116.111 and the API is https://api.publicapis.org/entries. on the web

If you locally call an IP (not a domain) with http, then you must set the router rule to it (Host(`1.2.3.4`)), so Traefik can match the incoming request and forward it to the according service.

Not sure you need this, it will redirect port 5000 to 443.

When you want to forward requests addressed to 127.0.0.2:5000 to the external url, then you need a router with rule = "Host(`127.0.0.2`)" to match the request.

hello i come back because i havn't solution:
but this my new configuration:
config.toml:
[accesslog]
[api]
insecure = true
dashboard = true
debug = true
[log]
level = "INFO"

[entryPoints]
[entryPoints.web]
address = ":80"

[entryPoints.nsia]
    address = "127.0.0.2:5000"
[entryPoints.nsia.http]
[entryPoints.nsia.http.redirections]
[entryPoints.nsia.http.redirections.entryPoint]
    to = "websecure"
    scheme = "https"
    permanent = true
    priority = 10

[entryPoints.websecure]
address = ":443"

[providers.file]
directory = "services/"
watch = true

traefik.toml (is in server folde: directory = "services/")
[http]
[http.routers]
[http.routers.traefik_route]
entryPoints = ["nsia"]
rule = "Host(127.0.0.2:5000) && Path(/api/*)"
middlewares = ["api-forwarding"]
service = "traefik"

[http.middlewares]
    [http.middlewares.api-forwarding.headers.customRequestHeaders]
        X-Forwarded-Host = "api.publicapis.org"
        X-Forwarded-Proto = "https"
        X-Forwarded-Port = "443"
        X-Forwarded-Uri = "/entries"


[http.services]
    [http.services.traefik]
        [http.services.traefik.loadBalancer]
            [[http.services.traefik.loadBalancer.servers]]
                url = "https://api.publicapis.org/entries"
            [[http.services.traefik.loadBalancer.servers]]
                url = "https://api.publicapis.org/entries"

NB: i'm on my local labtop

Format your code with 3 backticks in front and after, or select the code and press </> .

config.toml:

[accesslog]
[api]
insecure = true
dashboard = true
debug = true
[log]
level = "INFO"

[entryPoints]
[entryPoints.web]
address = ":80"

[entryPoints.nsia]
    address = "127.0.0.2:5000"
[entryPoints.nsia.http]
[entryPoints.nsia.http.redirections]
[entryPoints.nsia.http.redirections.entryPoint]
    to = "websecure"
    scheme = "https"
    permanent = true
    priority = 10

[entryPoints.websecure]
address = ":443"

[providers.file]
directory = "services/"
watch = true

traefik.toml (is in server folde: directory = "services/")
[http]
[http.routers]
[http.routers.traefik_route]
entryPoints = ["nsia"]
rule = "Host(127.0.0.2:5000) && Path(/api/*)"
middlewares = ["api-forwarding"]
service = "traefik"

[http.middlewares]
    [http.middlewares.api-forwarding.headers.customRequestHeaders]
        X-Forwarded-Host = "api.publicapis.org"
        X-Forwarded-Proto = "https"
        X-Forwarded-Port = "443"
        X-Forwarded-Uri = "/entries"


[http.services]
    [http.services.traefik]
        [http.services.traefik.loadBalancer]
            [[http.services.traefik.loadBalancer.servers]]
                url = "https://api.publicapis.org/entries"
            [[http.services.traefik.loadBalancer.servers]]
                url = "https://api.publicapis.org/entries"

Path() does exact matching, I don’t think you have a route called /api/*. Use PathPrefix(`/api/`) instead.

Traefik documentation is your friend. It is a lot, as Traefik has a lot of configuration options, but usually well written and with examples.

hello ok thank you,
i come back to you

Good morning
please,
how can I use traefik to invoke a web application,
I explain:
we work mainly on the intranet. To communicate with external partners we use VPNs.
today we want to use traefik to showcase our services. some of our services must in turn invoke services on the internet such as an Amazon API for example.
how to proceed. I am new so please explain with a junior level

Traefik is a reverse proxy, it mainly forwards http requests based on Host() and PathPrefix() to a target service/container.

Traefik can forward to any kind of service, it can be external (using dynamic config loadbalancer.servers.url, doc) as long as domain can be resolved with DNS and IP and port can be reached.

yes so far I have no problem with the basic principle, only when I put an external link at the service level
[http]
    [http.routers]
        [http.routers.router_web]
            entryPoints = ["web"]
            rule = "Host(`http://127.0.0.1:7080`)"
            middlewares = ["api-forwarding"]
            service="web"

    [http.services]
        [http.services.web]
            [http.services.web.loadBalancer]
                [[http.services.web.loadBalancer.servers]]
                    url = "http://developer.nytimes.com/livres.pdf/"
                [[http.services.traefik.loadBalancer.servers]]
                    url = "http://developer.nytimes.com/livres.pdf/"

however if I go to the link directly even with pod man I have the ok "200" ok

This looks wrong: rule = "Host(`http://127.0.0.1:7080`)", protocol and port should not be included. You can try rule = "Host(`127.0.0.1`)".

And if you want to use port 7080, make sure to create an entrypoint and open the container port.

Thank you for your help, step by step I am progressing and I understand better and better.
but I receive a 404 error when I test: 127.0.0.1 but it already changes to "https".
here is the complete code:

[http]
    [http.routers]
        [http.routers.traefik]
            entryPoints = ["nsia"]
            rule = "Host(`http://127.0.0.1`)"
            middlewares = ["api-forwarding"]
            service = "traefik"


    [http.middlewares]
        [http.middlewares.api-forwarding.headers.customRequestHeaders]
            X-Forwarded-Host = "https://jsonplaceholder.typicode.com/comments"
            X-Forwarded-Proto = "https"
            X-Forwarded-Port = "443"
            X-Forwarded-Uri = "/entries"


    [http.services]
        [http.services.traefik]
            [http.services.traefik.loadBalancer]
                [[http.services.traefik.loadBalancer.servers]]
                    url = "https://jsonplaceholder.typicode.com/comments"
                [[http.services.traefik.loadBalancer.servers]]
                    url = "https://jsonplaceholder.typicode.com/comments"



what is my mistake and what should I do

Again: Host() is just using domain or IP. You can not add protocol or port to the parameter, it will not work. RTFM

Check Traefik debug log and access log and Traefik dashboard for errors.

It needs to be the same domain/IP you access with your client/browser. If you request http://localhost then it needs to be Host(`localhost`).

Thank you for your feedback and sorry for my inattention.
I just corrected. my dashbord works without problem.
but I don't understand why the redirect gives me a 404 error.
is it because I am doing configuration on own machine in localHost (127.0.0.1) or there is another valid reason because for my test url: https://jsonplaceholder.typicode.com/comments,
returns a status 200 ok on postman with json.

code:
[http]
    [http.routers]
        [http.routers.traefik]
            entryPoints = ["nsia"]
            rule = "Host(`127.0.0.1`)"
            middlewares = ["api-forwarding"]
            service = "traefik"


    [http.middlewares]
        [http.middlewares.api-forwarding.headers.customRequestHeaders]
            X-Forwarded-Host = "https://jsonplaceholder.typicode.com/comments"
            X-Forwarded-Proto = "https"
            X-Forwarded-Port = "443"
            X-Forwarded-Uri = "/entries"


    [http.services]
        [http.services.traefik]
            [http.services.traefik.loadBalancer]
                [[http.services.traefik.loadBalancer.servers]]
                    url = "https://jsonplaceholder.typicode.com/comments"
                [[http.services.traefik.loadBalancer.servers]]
                    url = "https://jsonplaceholder.typicode.com/comments"


Need help