Treafik Path Routing - docker

I want to reach a docker-compose service under api.example.com/example. Therefore I have the following docker-compose.yml
example:
image: example
labels:
- "traefik.frontend.rule=Host:api.example.com;PathPrefixStrip:/example/"
- "traefik.enable=true"
- "traefik.protocol=http"
- "traefik.frontend.entryPoints=https"
I can reach the service under this path. But all the links in the page route to a wrong url like api.example.com/link instead of api.example.com/example/link
Also the css is not loading correctly because of this path issue.
What would be the right path configuration to get this working?
Reading from the docs, X-Forwarded-Prefix should be the solution, but there is no doc about.

If I understand correctly, you only want to route requests matching api.example.com/example/* to this example service. Then you should use PathPrefix:/example/.
What you have is expected: PathPrefixStrip, as the name suggests, try to match the path, then, remove it before routing traffic to the service.

Did you try to add rules ?
- "traefik.frontend.rule=Host:api.example.com;PathPrefixStrip:/example/; AddPrefix: /example"

Related

Drupal internalURL rewrite

I am trying to do something very simple, but can't seem to find a way to do it. What I want is to have a URL in the form of /en/products/accessories+software internally route to /en/products?accessories+software.
/en/products is an existing page, whatever comes after are basically filters, which are appended to the URL so they can be linked directly. Now it works by appending it as query parameters, but using /filtersHere would be preferred. But this of course results in a 404 error.
Site is running D9.
Why not use Drupal's Routing system and make dynamic arguments on URL?
In the module.routing.yml, something like below should do:
module.mypath:
# Dynamic arguments enclosed in { }.
path: '/book/export/{type}/{node}'
defaults:
_controller: '\Drupal\module\Controller\MyController::index'
More details available in the official doc:
Drupal - Structure of routes

HAproxy - How to match a given URL without any paths allowed?

I want forward traffic using an exactly matching URL e.g. test.example.com with a ACL rule in the given frontend. When test.example.com\path it should move to another backend. My setup is a little bit more complicated, means just specify an acl matching for the path for the given backend does not work for me.
ACL logic: use backend IF acl_match_exact_url FOR EVERYTHING ELSE acl_use_other_backend.
Is there a way only to match the URL via ACL?
If I understand your question correctly, you want an ACL that can match by host header and/or path. You can do that several ways, for example you can match the req.hdr(host) and path separately like so:
acl match_path path /path
acl match_host req.hdr(host) test.example.com
use_backend backend_one if match_path match_host
default_backend backend_two
You can also do this with base, which concatenates both host and path into one sample, e.g:
acl match_host_and_path base test.example.com/path
use_backend backend_one if match_host_and_path
default_backend backend_two

zuul forwarding to different urls having same prefix

i have 2 instances of a service running on different ports
zuul forwarding properties for both of them are
for v1:
zuul.routes.app.path=/app/**
zuul.routes.app.url=http://localhost:8081
and for v2
zuul.routes.app.path=/app/v2/**
zuul.routes.app.url=http://localhost:8082
all my request to api/v2 are going into app/ and not to api/v2 is there any way to configure v1 one to ignore calls for api/v2 and/or forward it to v2 url given that path for v1 cant be changed
Declare order of routes is important for zuul.
Described above happens because you have configured
zuul.routes.app.path=/app/**
eagerly consumes all responses. Try to configure in such order:
zuul.routes.app2.path=/app/v2/**
zuul.routes.app2.url=http://localhost:8082
zuul.routes.app1.path=/app/**
zuul.routes.app1.url=http://localhost:8081
So if it is specific call to
/app/v2/**
it will be matched first. If not, second match that consume all requests to
/app/**
...will be matched.
Note also, routes should be named differently:
app1, app2
You can also read about here. Hope this will help...

create route that points to a microservice method with zuul

Is it possible to create a route that points to a method inside a microservice?, I have a microservice called MsCargosAbonos that is discovered by my eureka server, inside my microservice I have a method called pago, my zuul application url is http://localhost:8000, I can call the microservice like this:
http://localhost:8000/mscargosabonos/pago
So I want to change the url above to:
http://localhost:8000/ejecutarPago
Is it possible to do this with zuul?
Thanks in advance.
I modify my application.yml like this:
zuul:
prefix: /api
routes:
pago:
path: /pago/**
url: http://localhost:8000/api/mspago/
I don't know if this is the correct way to do this so if someone has a better idea please share it with me, thanks.

Symfony use_javascript() routing issue

i am using symfony 1.4.11; use_helper('Url').
On using link_to('new',course/course/type/new),
the url it show is ../backend_dev/backend_dev/Course/course/type/new
instead of
../backend_dev/Course/course/type/new.
Same issue exist for form_tag also.
Edit
Above issue was solved.By setting no_script_name: true at config and clearing cache.
But image_tag(),use_stylesheet() and use_javascript() gives path as for example
use_javascript('jquery-1.6.1.min.js')
==>../web/backend_dev/js/jquery-1.6.1.min.js
instead of
use_javascript('jquery-1.6.1.min.js') ==>../web/js/jquery-1.6.1.min.js
Any help appreciated.
Hard to say without your full routing.yml but the one thing i see is that your internal_uri should be expressed as an abs url with a query string like:
link_to('new','/Course/course?type=new');
Note the forward slash at the beginning. Also the module name should be the real module name, not the routed one so if the maodule is /apps/backend/modules/Course then the module in the internal URI should be Course not course same with the action name.
If the route is named then you should use one of the following:
link_to('new','#routename?type=new');
OR
link_to('new','routename', array('type'=>'new'));

Resources