POST http redirect to POST https

Hi all,

I have a kind of issue here.
I have a website which is deployed with traefik. I would like to setup my website in http and request my API with some POST http method.
The problem is that, the POST http change into POST https.

This is my docker-compose.yml file:

version: "3.0"

networks:
  frontend:
    external: true
  backend:
    external: true

services:
  ### Traefik ########################################
  traefik:
    container_name: traefik
    image: traefik:1.7.5-alpine
    command: --docker
    networks:
      - frontend
      - backend
    ports:
      - 80:80
      - 443:443
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ./traefik/traefik.toml:/traefik.toml
      - ./traefik/acme.json:/acme.json
    labels:
      - traefik.backend=traefik
      - traefik.frontend.rule=Host:traefik.staging.fr
      - traefik.port=8080

  ### Api (Core)  ########################################
  api:
    container_name: api
    image: registry.gitlab.com/example/apps/api-core:dev
    labels:
      - traefik.backend=api
      - traefik.frontend.rule=Host:api.staging.fr
      - traefik.port=5000
    networks:
      - backend

  ### Webapp V1  ############################################
  webapp-v1:
    container_name: webapp-v1
    image: registry.gitlab.com/example/apps/angular-client:dev
    labels:
      - traefik.backend=webapp-v1
      - traefik.frontend.rule=Host:app.staging.fr
      - traefik.port=80
    networks:
      - frontend
      - backend

This is my traefik.toml :

defaultEntryPoints = ["http"]

[web]
address = ":8080"
[web.auth.basic]
  users = ["admin:admin"]

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

Debug Mode in Chrome :

Request URL: https://api.staging.fr/api/accounts/login
Error : OPTIONS https://api.staging.fr/api/accounts/login net::ERR_CONNECTION_REFUSED

I would like to request http://api.staging.fr/api/accounts/login but it request https://api.staging.fr/api/accounts/login

Is there a way to disable traefik changing POST http into POST https ?

Hello @Karbone4, there is nothing in your configuration that would seem to enable https.

Can you test your endpoint with curl instead of your browser?

curl -v  http://api.staging.fr/api/accounts/login

?

It is possible that you have cached redirects in your browser that may be interfering with your requests.

Hello @daniel.tomcej

Thats the curl response :

*   Trying 163.28.84.155...
* TCP_NODELAY set
* Connected to api.staging.fr (163.28.84.155) port 80 (#0)
> GET /api/accounts/login HTTP/1.1
> Host: api.staging.fr
> User-Agent: curl/7.52.1
> Accept: */*
>
< HTTP/1.1 401 Unauthorized
< Access-Control-Allow-Credentials: true
< Content-Type: application/json; charset=utf-8
< Date: Wed, 10 Jul 2019 09:46:04 GMT
< Strict-Transport-Security: max-age=0; includeSubDomains
< Vary: Origin, Accept-Encoding
< X-Content-Type-Options: nosniff
< X-Download-Options: noopen
< X-Frame-Options: DENY
< X-Xss-Protection: 1; mode=block
< Content-Length: 110
<
* Curl_http_done: called premature == 0
* Connection #0 to host api.staging.fr left intact
{"error":{"statusCode":401,"name":"Error","message":"Authorization Required","code":"AUTHORIZATION_REQUIRED"}}

I have tested with chrome and firefox and both request https.

If i use traefik v2, it could be better ?

I am wondering if that could come from nginx

Hello @Karbone4,

Your response from your application has HSTS enabled.

HSTS means that the browser can ONLY request https....