Answer the question
In order to leave comments, you need to log in
How to properly configure https for django on Nginx Proxy Manager?
Hello everyone, tell me why django does not see https? I have an ssl certificate, everything is set up, and on the site itself everything works on https, but when you receive request.get_scheme in the template, the result is http and requests also go with http, what can it be?
Everything is configured using 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
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;
}
}
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: {}
Answer the question
In order to leave comments, you need to log in
Where is the certificate? Nginx is configured for http judging by the given config.
Or is this Nginx located behind a proxy? If so, then check if the X-Forwarded-Proto header is transmitted from it
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question