Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I add custom routes to traefik? #328

Closed
WinstonN opened this issue Mar 19, 2021 · 11 comments
Closed

How can I add custom routes to traefik? #328

WinstonN opened this issue Mar 19, 2021 · 11 comments

Comments

@WinstonN
Copy link

WinstonN commented Mar 19, 2021

When I use NGROK, or localtunnel, to create a tunnel between my docker environment, and the internet, I always get a 404 page

This page seems to belong to traefik
I get the same page when I hit https://localhost:443

I want to ensure that when I use a service like localtunnel, and I set the local-host to the same as my local site, that I reach it and not a 404

an example command below

lt --local-host mysite.test --subdomain mysite --port 443
@davidalger
Copy link
Collaborator

@WinstonN The info here should be of help on this front: https://docs.warden.dev/configuration/multipledomains.html

@WinstonN
Copy link
Author

WinstonN commented Mar 22, 2021

@davidalger I have used that document, and have a setup like this currently

.warden/warden-env.yml

version: "3.5"
services:
    nginx:
        labels:
            - traefik.http.routers.${WARDEN_ENV_NAME}-nginx.rule=
                HostRegexp(`{subdomain:.+}.${TRAEFIK_DOMAIN}`)
                || Host(`${TRAEFIK_DOMAIN}`)
                || HostRegexp(`{subdomain:.+}.localhost`)
                || Host(`localhost`)
                || HostRegexp(`{subdomain:.+}.localhost.test`)
                || Host(`localhost.test`)
                || HostRegexp(`testsubdomain.loca.lt`)
                || Host(`testsubdomain.loca.lt`)
                || HostRegexp(`127.0.0.1`)
                || Host(`127.0.0.1`)
    php-fpm:
        extra_hosts:
            - localhost:${TRAEFIK_ADDRESS:-0.0.0.0}
            - localhost.test:${TRAEFIK_ADDRESS:-0.0.0.0}
            - testsubdomain.loca.lt:${TRAEFIK_ADDRESS:-0.0.0.0}
            - 127.0.0.1:${TRAEFIK_ADDRESS:-0.0.0.0}
    php-debug:
        extra_hosts:
            - localhost:${TRAEFIK_ADDRESS:-0.0.0.0}
            - localhost.test:${TRAEFIK_ADDRESS:-0.0.0.0}
            - testsubdomain.loca.lt:${TRAEFIK_ADDRESS:-0.0.0.0}
            - 127.0.0.1:${TRAEFIK_ADDRESS:-0.0.0.0}

When I open up

  • localhost
  • localhost.test
  • 127.0.0.1

My development site loads correctly

The problem I have is, using NGROK, or something like localtunnel, I always get a 404 - see image

How can I log that 404 page? It seems like it's a traefik/nginx page
The issue seems to be, DNS related?

image

@davidalger
Copy link
Collaborator

That's a generic 404 response from Traefik when the request doesn't match any of the configured routers (i.e. set of labels). You'll want to verify the host header Ngrok and/or Lt is passing on matches one of the routers the shows up in the dashboard: https://traefik.warden.test/dashboard/#/http/routers (and if one of your routes doesn't show up, try re-creating the container warden env up php-fpm --force-recreate

@WinstonN
Copy link
Author

WinstonN commented Mar 31, 2021

I had some time to look into this, I logged out the request headers (using a simple node server)

==== GET /
> Headers
{ 'x-forwarded-host': 'domain.loca.lt',
  'x-forwarded-port': '80',
  cookie: '_ga=GA1.2.565745458.161',
  'accept-language': 'en-NZ,en-US;q=0.9,en-GB;q=0.8,en;q=0.7',
  'accept-encoding': 'gzip, deflate, br',
  'sec-fetch-dest': 'document',
  'sec-fetch-user': '?1',
  'sec-fetch-mode': 'navigate',
  'sec-fetch-site': 'none',
  accept:
   'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
  'user-agent':
   'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36',
  'upgrade-insecure-requests': '1',
  'sec-ch-ua-mobile': '?0',
  'sec-ch-ua':
   '"Google Chrome";v="89", "Chromium";v="89", ";Not A Brand";v="99"',
  'cache-control': 'no-cache',
  pragma: 'no-cache',
  connection: 'close',
  'x-nginx-proxy': 'true',
  'x-forwarded-proto': 'https,http',
  host: 'domain.test',
  'x-forwarded-for': '101.53.111.255,::ffff:10.42.111.6',
  'x-real-ip': '101.53.111.255' }
> Body

I can see the host header is what it should be
My traefik routes is setup for domain.test

It's curious because the tunnel does reach my other node, django, apps
It's seems like it's a traefik / dns issue

image

@davidalger you wouldn't happen to know of a way to set the default traefik page (that shows the 404) to forward to ${TRAEFIK_DOMAIN} ?

@davidalger
Copy link
Collaborator

The only observation I can offer is is the rules provided don't appear to cover domain.loca.lt, which is the value of the X-Forwarded-Host header, and it might be that Traefik is looking at that header in lieu of Host when present.

@norgeindian
Copy link
Contributor

@WinstonN , if you have any more findings regarding this issue, it would be great if you could share them.
We are thinking about including ngrok or localtunnel as well, but it seems to be quite difficult together with the warden setup. So it would be awesome to know what else you already found out.

@WinstonN
Copy link
Author

WinstonN commented May 4, 2021

I'm not sure how to do this in warden, in theory it should work, but I haven't been able to get it working. Closing this issue

@sinisa86
Copy link

Create a run_ngrok.sh script with the content from following the url:

https://gist.github.com/sjb9774/7dd44d37c0001fd88ce4e1e819e2025b

Make sure you've updated the last line with name of project from .env file. After that, run that script on your local.
When you get your ngrok public URL, take it and update core_config_data's secure/unsecure urls, as well as cookie domain entry. Clear the cache, and it should work.

@MagePsycho
Copy link

Have someone had any success with warden + ngrok?
Would like to hear more about it.

1 similar comment
@palejosdeuna
Copy link

Have someone had any success with warden + ngrok?
Would like to hear more about it.

@palejosdeuna
Copy link

Alguien pudo solucionar este tema ? si es así podrían compartir la solución ?

@wardenenv wardenenv locked and limited conversation to collaborators Dec 22, 2022
@navarr navarr converted this issue into discussion #563 Dec 22, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants