Всем привет, подскажите почему django не видит https? У меня есть сертификат ssl, всё настроено, и на самом сайте всё работает на https, но когда в шаблоне получаешь request.get_scheme то результат http и запросы идут тоже с http, что это может быть?
Настроено всё с помощью NGINX Proxy Manager - docker-compose:
version: "3"
services:
app:
image: 'jc21/nginx-proxy-manager:latest'
networks:
testnet:
ipv4_address: 172.26.0.254
restart: always
ports:
# Public HTTP Port:
- '80:80'
# Public HTTPS Port:
- '443:443'
# Admin Web Port:
- '81:81'
environment:
# These are the settings to access your db
DB_MYSQL_HOST: "172.26.0.253"
DB_MYSQL_PORT: 3306
DB_MYSQL_USER: "user"
DB_MYSQL_PASSWORD: "pwd"
DB_MYSQL_NAME: "npm"
volumes:
- ./data/nginx-proxy-manager:/data
- ./letsencrypt:/etc/letsencrypt
depends_on:
- db
db:
image: yobasystems/alpine-mariadb:latest
restart: always
networks:
testnet:
ipv4_address: 172.26.0.253
environment:
MYSQL_ROOT_PASSWORD: "pwd"
MYSQL_DATABASE: "npm"
MYSQL_USER: "user"
MYSQL_PASSWORD: "pwd"
volumes:
- ./data/mariadb:/var/lib/mysql
networks:
testnet:
external: true
Настройки nginx на самом сайте:
server {
listen 80 default_server;
server_name testss.top;
location /static/ {
root /var/www/testss;
}
location /media/ {
root /var/www/testss;
}
location / {
add_header X-Cache-Status $upstream_cache_status;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://backend:8008;
}
}
Docker-compose сайта:
version: '3'
services:
backend:
build: ./
container_name: testss_container
restart: always
command: ./commands/start_server.sh
networks:
testnet:
ipv4_address: 172.26.0.2
volumes:
- ./src:/srv/project/src
- ./commands:/srv/project/commands
- static_content:/var/www/testss
env_file:
- .env
depends_on:
- postgres
postgres:
image: postgres:12
volumes:
- pg_data:/var/lib/postgresql/data
env_file:
- .env
networks:
testnet:
ipv4_address: 172.26.0.4
# environment:
# - DJANGO_SETTINGS_MODULE=testss.settings.${MODE}
nginx:
image: nginx:1.19
volumes:
- ./nginx:/etc/nginx/conf.d
- static_content:/var/www/testss
networks:
testnet:
ipv4_address: 172.26.0.5
env_file:
- .env
depends_on:
- backend
networks:
testnet:
external: true
volumes:
pg_data: {}
static_content: {}