mirror of
https://github.com/AudebertAdrien/ft_transcendence.git
synced 2025-12-16 14:07:49 +01:00
nginx and favicon done
This commit is contained in:
parent
f5c5c5dd7f
commit
39b6f1a17c
@ -1,9 +1,11 @@
|
||||
server {
|
||||
listen 80;
|
||||
#server_name yourdomain.com;
|
||||
server_name localhost;
|
||||
|
||||
# Redirect HTTP to HTTPS
|
||||
return 301 https://$host$request_uri;
|
||||
location / {
|
||||
return 301 https://localhost:1443$request_uri;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
@ -16,12 +18,9 @@ server {
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
ssl_prefer_server_ciphers on;
|
||||
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
# Proxy normal HTTP requests to Django
|
||||
location / {
|
||||
proxy_pass http://backend:8080;
|
||||
proxy_pass http://backend:8080/;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
|
||||
28
config/ssl.conf
Normal file
28
config/ssl.conf
Normal file
@ -0,0 +1,28 @@
|
||||
[req]
|
||||
distinguished_name = req_distinguished_name
|
||||
req_extensions = req_ext
|
||||
x509_extensions = req_ext
|
||||
|
||||
[req_distinguished_name]
|
||||
countryName = FR
|
||||
countryName_default = FR
|
||||
stateOrProvinceName = Pyrénées Orientales
|
||||
stateOrProvinceName_default = Pyrénées Orientales
|
||||
localityName = Perpignan
|
||||
localityName_default = Perpignan
|
||||
organizationName = 42Perpignan
|
||||
organizationName_default = 42Perpignan
|
||||
commonName = www.ft_transcendence.com
|
||||
commonName_default = localhost
|
||||
|
||||
[req_ext]
|
||||
subjectAltName = @alt_names
|
||||
basicConstraints = CA:FALSE
|
||||
keyUsage = digitalSignature, keyEncipherment
|
||||
extendedKeyUsage = serverAuth
|
||||
|
||||
[alt_names]
|
||||
DNS.1 = localhost
|
||||
DNS.2 = www.ft_transcendence.com
|
||||
DNS.3 = ft_transcendence.com
|
||||
IP.1 = 127.0.0.1
|
||||
@ -3,8 +3,8 @@ services:
|
||||
image: nginx:latest
|
||||
container_name: nginx
|
||||
ports:
|
||||
- "80:80"
|
||||
- "443:443"
|
||||
- "1080:80"
|
||||
- "1443:443"
|
||||
volumes:
|
||||
- ./config/nginx.conf:/etc/nginx/conf.d/default.conf
|
||||
- ./certs/ssl:/etc/nginx/ssl
|
||||
@ -24,7 +24,7 @@ services:
|
||||
venv/bin/python manage.py makemigrations --noinput &&
|
||||
venv/bin/python manage.py migrate --noinput &&
|
||||
venv/bin/python manage.py collectstatic --noinput &&
|
||||
venv/bin/daphne -e ssl:8080:privateKey=./certs/ssl/backend-key.pem:certKey=./certs/ssl/backend-cert.pem pong.asgi:application"
|
||||
venv/bin/daphne -b 0.0.0.0 -p 8080 pong.asgi:application"
|
||||
volumes:
|
||||
- pong:/transcendence/pong
|
||||
- pong_django_logs:/transcendence/logs
|
||||
@ -38,7 +38,7 @@ services:
|
||||
DB_NAME: ${POSTGRES_DB}
|
||||
DB_USER: ${POSTGRES_USER}
|
||||
DB_PASSWORD: ${POSTGRES_PASSWORD}
|
||||
SECURE_SSL_REDIRECT: True
|
||||
SECURE_SSL_REDIRECT: False
|
||||
SECURE_HSTS_SECONDS: 31536000
|
||||
SECURE_HSTS_INCLUDE_SUBDOMAINS: True
|
||||
SECURE_HSTS_PRELOAD: True
|
||||
|
||||
10
makefile
10
makefile
@ -22,7 +22,10 @@ down:
|
||||
destroy:
|
||||
$(COMPOSE) down -v --rmi all
|
||||
|
||||
re : down destroy up
|
||||
ssl-certs:
|
||||
openssl req -x509 -nodes -days 365 -newkey rsa:4096 \
|
||||
-keyout certs/ssl/private.key -out certs/ssl/certificate.crt \
|
||||
-config config/ssl.conf
|
||||
|
||||
# Manage ELK stack
|
||||
|
||||
@ -42,9 +45,6 @@ kill-pid:
|
||||
sudo lsof -i :8080 | awk 'NR>1 {print $$2}' | xargs sudo kill -9 || true
|
||||
sudo lsof -i :5044 | awk 'NR>1 {print $$2}' | xargs sudo kill -9 || true
|
||||
|
||||
ps:
|
||||
$(COMPOSE) ps
|
||||
|
||||
db-shell:
|
||||
$(COMPOSE) exec db psql -U 42student players_db
|
||||
|
||||
@ -57,7 +57,7 @@ help:
|
||||
@echo " make destroy # Stop and remove containers and volumes"
|
||||
@echo " make stop [c=service] # Stop containers"
|
||||
@echo " make logs [c=service] # Tail logs of containers"
|
||||
@echo " make ps # List containers"
|
||||
@echo " make ssl-certs # create ssl certificate"
|
||||
@echo " make help # Show this help"
|
||||
|
||||
.PHONY: up build start stop down destroy logs ps db-shell help
|
||||
|
||||
@ -13,18 +13,6 @@ from pathlib import Path
|
||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||
|
||||
# Force HTTPS by redirecting HTTP traffic to HTTPS
|
||||
#SECURE_SSL_REDIRECT = True
|
||||
|
||||
# Set secure cookie flags to ensure they are only sent over HTTPS
|
||||
SESSION_COOKIE_SECURE = True
|
||||
CSRF_COOKIE_SECURE = True
|
||||
|
||||
# Enforce HTTP Strict Transport Security (HSTS)
|
||||
SECURE_HSTS_SECONDS = 31536000 # One year
|
||||
SECURE_HSTS_INCLUDE_SUBDOMAINS = True
|
||||
SECURE_HSTS_PRELOAD = True
|
||||
|
||||
# Quick-start development settings - unsuitable for production
|
||||
# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
|
||||
|
||||
|
||||
BIN
pong/static/favicon.ico
Normal file
BIN
pong/static/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
@ -7,6 +7,7 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Pong Game</title>
|
||||
<link rel="stylesheet" type="text/css" href="{% static 'styles.css' %}?v=3">
|
||||
<link rel="icon" type="image/x-icon" href="{% static 'favicon.ico' %}?v=2" >
|
||||
<div class="logo">
|
||||
<img src="{% static 'logo-42-perpignan.png' %}" alt="Logo">
|
||||
</div>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user