Azure Application Gateway + SSL & Traefik --> Getting 404 not found error

Hi Everyone,

Need your urgent help !!!

I am using Azure Application Gateway + SSL --> Traefik Proxy --> Backemd Dockerized Application Port 8080 (Containers with respect to branches).

We have written a rule in the Gitlab pipeline to create a new container with respect to the branch.

  • docker run -d --rm --name {CI_COMMIT_REF_NAME}-mapping-tools -l traefik.enable=true -l 'traefik.http.routers.'{CI_COMMIT_REF_SLUG}'-mapping-tools.rule=Host("'{CI_COMMIT_REF_SLUG}'-mapping-tools.mapping.web24.com")' {RELEASE_IMG}

master branch --> master container with 8080 port
URL will be created as http://master.mapping-tools.mapping.web24.com (This URL is absolutely working fine)

develop branch --> develop container with 8080 port
URL will be created as http://develop.mapping-tools.mapping.web24.com (This URL is absolutely working fine)

The above URLs works well without SSL but when we apply SSL on Application Gateway & try to access the HTTPS URL then it's giving us "404 not found" error.

https://master.mapping-tools.mapping.web24.com

https://develop.mapping-tools.mapping.web24.com


Traefik.toml :

[api]
dashboard = true
[providers.docker]
exposedByDefault = false
[providers.file]
filename = "/etc/traefik/dynamic.toml"
[log]
filePath = "/var/log/traefik/log-file.log"
format = "json"
level = "DEBUG"

[accessLog]
filePath = "/var/log/traefik/access.log"
bufferingSize = 1000
format = "json"

[accessLog.fields]
defaultMode = "keep"


dynamic.toml :

[http.routers.traefik]
rule = "Host(traefik.mapping.web24.com)"
service = "api@internal"
middlewares = ["traefikauth"]
[http.middlewares.traefikauth.ipWhiteList]
sourceRange = ["0.0.0.0/0"]


Access Logs:
{"ClientAddr":"10.0.5.6:29082","ClientHost":"10.0.5.6","ClientPort":"29082","ClientUsername":"-","DownstreamContentSize":19,"DownstreamStatus":404,"Duration":154299,"OriginContentSize":19,"OriginDuration":21100,"OriginStatus":404,"Overhead":133199,"RequestAddr":"10.0.4.4:80","RequestContentSize":0,"RequestCount":989,"RequestHost":"10.0.4.4","RequestMethod":"GET","RequestPath":"/","RequestPort":"80","RequestProtocol":"HTTP/1.1","RequestScheme":"http","RetryAttempts":0,"StartLocal":"2021-02-14T19:16:23.536365789Z","StartUTC":"2021-02-14T19:16:23.536365789Z","entryPointName":"http","level":"info","msg":"","time":"2021-02-14T19:16:23Z"}

Please Note 10.0.4.4 is the IP address of the Docker Hot which these containers are running.


Please help me to get this resolved.

Looks like traefik is not getting the Host passed through from azure api gateway. You're getting 10.0.4.4.

Can't help further right this minute. But that'ss what I get on first glance.

1 Like

Thanks for your reply @cakiwi

With SSL :

ClientAddr: '10.0.5.6:33270'
ClientHost: 10.0.5.6
ClientPort: '33270'
ClientUsername: '-'
DownstreamContentSize: 19
DownstreamStatus: 404
Duration: 148200
OriginContentSize: 19
OriginDuration: 16800
OriginStatus: 404
Overhead: 131400
RequestAddr: 127.0.0.1
RequestContentSize: 0
RequestCount: 37
RequestHost: 127.0.0.1
RequestMethod: GET
RequestPath: /
RequestPort: '-'
RequestProtocol: HTTP/1.1
RequestScheme: http
RetryAttempts: 0
StartLocal: '2021-02-15T20:19:59.681482861Z'
StartUTC: '2021-02-15T20:19:59.681482861Z'
entryPointName: http
level: info
msg: ''
time: '2021-02-15T20:19:59Z'


Without SSL (HTTP):

ClientAddr: '13.95.220.127:44890'
ClientHost: 13.95.220.127
ClientPort: '44890'
ClientUsername: '-'
DownstreamContentSize: 0
DownstreamStatus: 304
Duration: 2411398
OriginContentSize: 0
OriginDuration: 2254998
OriginStatus: 304
Overhead: 156400
RequestAddr: develop-mapping-tools.mapping.web24.com
RequestContentSize: 0
RequestCount: 3515
RequestHost: develop-mapping-tools.mapping.web24.com
RequestMethod: GET
RequestPath: /
RequestPort: '-'
RequestProtocol: HTTP/1.1
RequestScheme: http
RetryAttempts: 0
RouterName: develop-mapping-tools@docker
ServiceAddr: '172.17.0.3:8080'
ServiceName: develop-mapping-tools@docker
ServiceURL:
Scheme: http
Opaque: ''
User: null
Host: '172.17.0.3:8080'
Path: ''
RawPath: ''
ForceQuery: false
RawQuery: ''
Fragment: ''
StartLocal: '2021-02-15T10:06:44.132900476Z'
StartUTC: '2021-02-15T10:06:44.132900476Z'
entryPointName: http
level: info
msg: ''
time: '2021-02-15T10:06:44Z'

Now I am getting "502 Bad Gateway" Error.

Can someone please help me to resolve this issue?