首页 > 解决方案 > 使用 https 请求 django API 不起作用

问题描述

当我想使用 https 请求 API 时,它不起作用,我不知道为什么..

例子 :

`http://myIp:8888/getValue` --> it works
`https://myIp:8888/getValue` --> it doesn't work

有我的 dockerfile :

FROM python:3.7-buster
ENV PYTHONUNBUFFERED=1
WORKDIR /code
COPY requirements.txt /code/
RUN pip install -r requirements.txt
COPY . /code/

ENV PYTHONUNBUFFERED 1
ENV LANG C.UTF-8
ENV DEBIAN_FRONTEND=noninteractive

ENV PORT=8888

RUN apt-get update && apt-get install -y --no-install-recommends \
        tzdata \
        python3-setuptools \
        python3-pip \
        python3-dev \
        python3-venv \
        git \
        && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*

EXPOSE 8888

CMD gunicorn Documents_management_back.wsgi:application --bind 0.0.0.0:$PORT

还有我的 docker-compose

version: "3.9"

services:
  web:
    build: .
    command: python manage.py runserver 0.0.0.0:8000
    volumes:
      - .:/code
    ports:
      - "8000:8000"

有人明白为什么我不能请求使用 https 吗?

非常感谢 !

标签: pythondjangodocker

解决方案


推荐阅读