Traefik: a simple request return 302 via traefik

Created on 30 Jan 2018  路  3Comments  路  Source: traefik/traefik

Do you want to request a feature or report a bug?

bug

What did you do?

i user docker to run latest traefik image

docker run -d -p 8888:8080 -p 8880:80 -v $PWD/traefik.sample.toml:/etc/traefik/traefik.toml traefik

and the config file is

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

[file]
    [backends]
        [backends.local]
            [backends.local.servers.all]
            url = "http://172.18.49.244:9000/"

    [frontends]
        [frontends.local]
        backend = "local"
            [frontends.local.routes.all]
            rule = "Path:/appmonitor/"

than i use chrome to acess http://172.25.16.190:8880/appmonitor/

What did you expect to see?

i want to see web page and browser address should be keep as http://172.25.16.190:8880/appmonitor/

What did you see instead?

i see the web pages , but browser address is http://172.18.49.244:9000/

Output of traefik version: (_What version of Traefik are you using?_)

v1.5.1

latest image


What is your environment & configuration (arguments, toml, provider, platform, ...)?

linux


image

ee

but in nginx, there is no error and everything matchs my expect

location /appmonitor/ {
            proxy_pass http://localhost:9000/;
        }

it's a bug or any config error?

kinquestion statu5-frozen-due-to-age

Most helpful comment

@ldez using PathPrefix can not resolve the issue, the location header can not be rewrited

All 3 comments

I change my config

[frontends]
        [frontends.local]
        passHostHeader = true
        backend = "local"
            [frontends.local.routes.all]
            rule = "PathPrefixStrip:/appmonitor/"

i use a capture tool to check the request:
traefik give a request to backend

POST /login HTTP/1.1
Host: 127.0.0.1:9999
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36
Content-Length: 32
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Accept-Encoding: gzip, deflate
Accept-Language: en,zh-CN;q=0.9,zh;q=0.8,en-US;q=0.7,fr;q=0.6
Cache-Control: no-cache
Content-Type: application/x-www-form-urlencoded
Cookie: session=.eJwdjsGKwjAURX9leGsX09psCrMQkgkV8kIlGvI2wtRqmkk2dUQb8d8NszyXA_c84Xiex6uH9m--jSs4Tidon_DxAy2gJI-WImZMznZrZ3EiuQ2aU0BZOHWLNupTm65CK9YqfUfiQ0XhkJBv7mREQ1LUxWlcRq-CYNoMlTIxudzf0RwC8T1zdld4F8u2oPFT-fHIh5r4JTsTfylcFs27BxrBVN0_lN3XGAamZd-o3DPNxRe8VnC7jvN_P1TwegMTSEaX.DUw8OA.i8cBgNKpDvFfjcwjS_i6ITQSJ5E; JSESSIONID.0ae5ea01=l7kdtie9fbxm1n3fzhcb1768c; screenResolution=1440x900; JSESSIONID.f1a2aae4=1fu7m0es9xd0omt5tcf3lg84t; JSESSIONID.a5a42a88=o0f6ukjavgv2sh9k0xcxxmiy; JSESSIONID.9fb8302f=1wh3m473jzwv21dvcuaxok3nj2; JSESSIONID.032b09eb=usjz95xo477k12ilm99ibt2p7; JSESSIONID=8C5FE36631A6B07372D121A40385ADEA
Origin: http://172.25.16.190:8880
Pragma: no-cache
Referer: http://172.25.16.190:8880/appmonitor/login.html
Upgrade-Insecure-Requests: 1
X-Forwarded-For: 172.18.49.244
X-Forwarded-Host: 172.25.16.190:8880
X-Forwarded-Port: 8880
X-Forwarded-Prefix: /appmonitor/
X-Forwarded-Proto: http
X-Forwarded-Server: 9ff4afbcafd1
X-Real-Ip: 172.18.49.244

and backend response

HTTP/1.1 302 
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST, PUT, GET, OPTIONS, DELETE
Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization, _node_, X-ebao-tenant-id, X-ebao-vender-version, session, AG-Access-Key, AG-Signature, AG-Sign-Headers
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Frame-Options: DENY
Set-Cookie: JSESSIONID=8844DCFC50B85706DAE48DCCEEFCDB6E;path=/;HttpOnly
Location: http://172.25.16.190:8880/
Content-Length: 0
Date: Tue, 30 Jan 2018 08:48:39 GMT

then traefik return

Location:` http://172.25.16.190:8880/

to browser

so the issue happens. i expect traefik to rewrite the Location Header to http://172.25.16.190:8880/appmonitor/

why traefik lost the /appmonitor/

Thanks for your interest in Traefik !

Every question asked in issues means less features 馃槈.

The issue tracker is for reporting bugs and feature requests only.
For end-user related support questions, refer to one of the following:


With PathPrefixStrip the prefix is removed.
With Path -> the match must be exact.

You must use PathPrefix

@ldez using PathPrefix can not resolve the issue, the location header can not be rewrited

Was this page helpful?
0 / 5 - 0 ratings