Skip to content
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

Cannot pass host header #3822

Closed
john199604 opened this issue Aug 27, 2018 · 1 comment
Closed

Cannot pass host header #3822

john199604 opened this issue Aug 27, 2018 · 1 comment

Comments

@john199604
Copy link

john199604 commented Aug 27, 2018

Hello,

I have a .NET Core API and Angular 5 app which i am using traefik for the requests to go throught.

Here's my traefik.toml

debug = false
defaultEntryPoints = ["http", "https"]
[entryPoints]
   [entryPoints.http]
   address = ":80"
   [entryPoints.https]
   address = ":443"
     [entryPoints.https.tls]
       [[entryPoints.https.tls.certificates]]
       CertFile = "/etc//ssl/cert.pem"
       KeyFile = "/etc/ssl/key.pem"
[web]
ReadOnly = true
[docker]
endpoint = "unix:///var/run/docker.sock"
domain = "docker.localhost"
watch = true

My docker-compose file looks like this:

version: '2'

services:
  servercore:
    build: ./ServerCore
    restart: unless-stopped
    environment:
      DisplayName: ${DisplayName}
    labels:
      - traefik.backend=servercore
      - traefik.frontend.rule=Host:servercore.docker.localhost

  angular:
    build: ../actibook-frontend
    restart: unless-stopped
    labels:
      - traefik.backend=angular
      - traefik.frontend.rule=PathPrefix:/
      - traefik.enable=true
      - traefik.port=4200
      - traefik.frontend.passHostHeader=true
      - traefik.frontend.headers.customRequestHeaders=Host:servercore.docker.localhost

  traefik:
    build: ./traefik
    ports:
      - "80:80"
      - "443:443"
      - "8000:8080"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    restart: unless-stopped

But when I am adding "Host" header to requests when sending from Angular to Servercore it shows me this error:

Refused to set unsafe header "Host"

Shouldnt traefik.frontend.passHostHeader=true or traefik.frontend.headers.customRequestHeaders=Host:servercore.docker.localhost make that possible?

Thank you.

@mmatur mmatur added priority/P2 need to be fixed in the future kind/bug/possible a possible bug that needs analysis before it is confirmed or fixed. and removed status/0-needs-triage labels Aug 27, 2018
@juliens juliens added kind/question a question and removed kind/bug/possible a possible bug that needs analysis before it is confirmed or fixed. priority/P2 need to be fixed in the future labels Oct 8, 2018
@juliens
Copy link
Member

juliens commented Oct 8, 2018

Thanks for your interest in the project.

The message Refused to set unsafe header "Host" is not a Traefik problem. It's a security message from your browser. You can not change the Host header in an ajax request.

If you have questions and need community support, you can join our Slack workspace and reach out to us on the #support channel.

@juliens juliens closed this as completed Oct 8, 2018
@traefik traefik locked and limited conversation to collaborators Sep 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants