Traefik:对HTTPS URL的Ajax调用导致混合内容,不安全的XMLHttpRequest请求错误

时间:2019-03-28 09:28:31

标签: javascript ajax xmlhttprequest lets-encrypt traefik

我的Web应用程序上的所有ajax调用都出现此错误。

Mixed Content: The page at 'https://one.mydomain.com' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://one.mydomain.com/api/get-all-agents/'. This request has been blocked; the content must be served over HTTPS.

代码还以https上的绝对URL的形式发出了请求。

所有应用程序都在docker容器上运行。通过Traefik代理请求。

我尝试在请求中添加反斜杠无济于事。

进行调用的代码

var admin_base_url = "https://one.mydomain.com/

var url = admin_base_url + "api/get-all-agents/";

          $http.get(url).success(function(response){
              $scope.agents = response.agents;

          });

这是我的Traefik toml配置

debug = false

logLevel = "ERROR"
defaultEntryPoints = ["https","http"]

[entryPoints]
  [entryPoints.http]
  address = ":80"
    [entryPoints.http.redirect]
    entryPoint = "https"
  [entryPoints.https]
  address = ":443"
  [entryPoints.https.tls]

[retry]

[docker]
endpoint = "unix:///var/run/docker.sock"
domain = "mydomain.com"
watch = true
exposedByDefault = false

[acme]
email = "user@mydomain.com"
acmeLogging = false
storage = "acme.json"
entryPoint = "https"
onHostRule = true
[acme.httpChallenge]
entryPoint = "http"

和我的撰写文件

version: '3'

services:
  traefik:
    image: traefik:v1.7-alpine
    container_name: traefik
    restart: unless-stopped
    networks:
      - webgateway
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /home/ec2-user/traefik/traefik.toml:/traefik.toml
networks:
  webgateway:
    driver: bridge

和我的应用程序组成的标签

 labels:
      traefik.enable : "true"
      traefik.application.frontend.rule : "Host:one.mydomain.com"
      traefik.application-adminportal.port : "80"
    networks:
      - web

我已经在应用程序标签中添加了X-Forwarded-Proto = "https",但仍然存在相同的问题。

在这里提问之前,我查看了问题模型建议的所有链接。

请帮助。

更新

浏览器从HTTPS重定向到HTTP,然后HTTP请求导致错误 enter image description here

0 个答案:

没有答案