Base
This commit is contained in:
17
nginx/Dockerfile
Normal file
17
nginx/Dockerfile
Normal file
@ -0,0 +1,17 @@
|
||||
FROM alpine:3.19
|
||||
|
||||
RUN apk update
|
||||
|
||||
RUN apk add nginx
|
||||
RUN mkdir -p /etc/nginx/ssl
|
||||
RUN apk add openssl
|
||||
RUN openssl req -newkey rsa:4096 -x509 -sha256 -days 365 -nodes -out /etc/nginx/ssl/ping.crt -keyout /etc/nginx/ssl/ping.key -subj "/C=CH/ST=Vaud/L=Renens/O=42/OU=42/CN=ft_archive"
|
||||
RUN mkdir -p /var/run/nginx
|
||||
RUN mkdir -p /usr/share/nginx/html
|
||||
RUN mkdir -p /usr/share/nginx/static
|
||||
COPY ./conf/default /etc/nginx/conf.d/default.conf
|
||||
COPY ./conf/nginx.conf /etc/nginx/nginx.conf
|
||||
COPY ./static /usr/share/nginx/static
|
||||
COPY ./html /usr/share/nginx/html
|
||||
|
||||
CMD [ "nginx", "-g", "daemon off;" ]
|
||||
66
nginx/conf/default
Normal file
66
nginx/conf/default
Normal file
@ -0,0 +1,66 @@
|
||||
server {
|
||||
listen 80 default_server;
|
||||
listen [::]:80 default_server;
|
||||
server_name _;
|
||||
|
||||
location / {
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl;
|
||||
listen [::]:443 ssl;
|
||||
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
ssl_certificate /etc/nginx/ssl/ping.crt;
|
||||
ssl_certificate_key /etc/nginx/ssl/ping.key;
|
||||
|
||||
server_name archive;
|
||||
|
||||
location /ws/status/ {
|
||||
proxy_pass http://user:8003;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection $connection_upgrade;
|
||||
proxy_set_header Host $host;
|
||||
proxy_cache_bypass $http_upgrade;
|
||||
|
||||
#disable buffering for websockets
|
||||
proxy_buffering off;
|
||||
}
|
||||
|
||||
location /chat/ {
|
||||
proxy_pass http://chat:8004;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection $connection_upgrade;
|
||||
proxy_set_header Host $host;
|
||||
proxy_cache_bypass $http_upgrade;
|
||||
}
|
||||
|
||||
location /users_list/ {
|
||||
proxy_pass http://chat:8004;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
}
|
||||
|
||||
location /auth/ {
|
||||
proxy_pass http://user:8003;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
}
|
||||
|
||||
location /static/ {
|
||||
alias /usr/share/nginx/static/;
|
||||
}
|
||||
|
||||
location /media/ {
|
||||
alias /home/archive/user_auth_system/media/;
|
||||
}
|
||||
|
||||
location / {
|
||||
alias /usr/share/nginx/html/;
|
||||
try_files $uri /index.html;
|
||||
}
|
||||
}
|
||||
103
nginx/conf/nginx.conf
Normal file
103
nginx/conf/nginx.conf
Normal file
@ -0,0 +1,103 @@
|
||||
# /etc/nginx/nginx.conf
|
||||
|
||||
user nginx;
|
||||
|
||||
# Set number of worker processes automatically based on number of CPU cores.
|
||||
worker_processes auto;
|
||||
|
||||
# Enables the use of JIT for regular expressions to speed-up their processing.
|
||||
pcre_jit on;
|
||||
|
||||
# Configures default error logger.
|
||||
error_log /var/log/nginx/error.log warn;
|
||||
|
||||
# Includes files with directives to load dynamic modules.
|
||||
include /etc/nginx/modules/*.conf;
|
||||
|
||||
# Include files with config snippets into the root context.;
|
||||
|
||||
events {
|
||||
# The maximum number of simultaneous connections that can be opened by
|
||||
# a worker process.
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
# Includes mapping of file name extensions to MIME types of responses
|
||||
# and defines the default type.
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
# Name servers used to resolve names of upstream servers into addresses.
|
||||
# It's also needed when using tcpsocket and udpsocket in Lua modules.
|
||||
#resolver 1.1.1.1 1.0.0.1 2606:4700:4700::1111 2606:4700:4700::1001;
|
||||
|
||||
# Don't tell nginx version to the clients. Default is 'on'.
|
||||
server_tokens off;
|
||||
|
||||
# Specifies the maximum accepted body size of a client request, as
|
||||
# indicated by the request header Content-Length. If the stated content
|
||||
# length is greater than this size, then the client receives the HTTP
|
||||
# error code 413. Set to 0 to disable. Default is '1m'.
|
||||
client_max_body_size 2m;
|
||||
|
||||
# Sendfile copies data between one FD and other from within the kernel,
|
||||
# which is more efficient than read() + write(). Default is off.
|
||||
sendfile on;
|
||||
|
||||
# Causes nginx to attempt to send its HTTP response head in one packet,
|
||||
# instead of using partial frames. Default is 'off'.
|
||||
tcp_nopush on;
|
||||
|
||||
|
||||
# Enables the specified protocols. Default is TLSv1 TLSv1.1 TLSv1.2.
|
||||
# TIP: If you're not obligated to support ancient clients, remove TLSv1.1.
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
|
||||
# Path of the file with Diffie-Hellman parameters for EDH ciphers.
|
||||
# TIP: Generate with: `openssl dhparam -out /etc/ssl/nginx/dh2048.pem 2048`
|
||||
#ssl_dhparam /etc/ssl/nginx/dh2048.pem;
|
||||
|
||||
# Specifies that our cipher suits should be preferred over client ciphers.
|
||||
# Default is 'off'.
|
||||
ssl_prefer_server_ciphers on;
|
||||
|
||||
# Enables a shared SSL cache with size that can hold around 8000 sessions.
|
||||
# Default is 'none'.
|
||||
ssl_session_cache shared:SSL:2m;
|
||||
|
||||
# Specifies a time during which a client may reuse the session parameters.
|
||||
# Default is '5m'.
|
||||
ssl_session_timeout 1h;
|
||||
|
||||
# Disable TLS session tickets (they are insecure). Default is 'on'.
|
||||
ssl_session_tickets off;
|
||||
|
||||
|
||||
# Enable gzipping of responses.
|
||||
#gzip on;
|
||||
|
||||
# Set the Vary HTTP header as defined in the RFC 2616. Default is 'off'.
|
||||
gzip_vary on;
|
||||
|
||||
|
||||
# Helper variable for proxying websockets.
|
||||
map $http_upgrade $connection_upgrade {
|
||||
default upgrade;
|
||||
'' close;
|
||||
}
|
||||
|
||||
|
||||
# Specifies the main log format.
|
||||
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
||||
'$status $body_bytes_sent "$http_referer" '
|
||||
'"$http_user_agent" "$http_x_forwarded_for"';
|
||||
|
||||
# Sets the path, format, and configuration for a buffered log write.
|
||||
access_log /var/log/nginx/access.log main;
|
||||
|
||||
|
||||
# Includes virtual hosts configs.
|
||||
# include /etc/nginx/http.d/*.conf;
|
||||
include /etc/nginx/conf.d/*.conf;
|
||||
}
|
||||
37
nginx/html/index.html
Normal file
37
nginx/html/index.html
Normal file
@ -0,0 +1,37 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Archive de Liens</title>
|
||||
<link rel="stylesheet" href='/static/styles/styles.css'>
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.5.0/font/bootstrap-icons.css">
|
||||
<link rel="icon" type="image/x-icon" href='/static/favicon.ico'>
|
||||
<script type="module" src='/static/scripts/main.js'></script>
|
||||
<script type="module" src='/static/scripts/router.js'></script>
|
||||
<script type="module" src='/static/scripts/navigation.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<nav>
|
||||
<div id="tabs-icon">
|
||||
<div id="tabs-list">
|
||||
<button type="button" id="home-button">ACCUEIL <i class="bi bi-house-door"></i></button>
|
||||
<button type="button" id="sources-button">SOURCES <i class="bi bi-link-45deg"></i></button>
|
||||
<button type="button" id="suggest-button">SUGGÉRER <i class="bi bi-plus-circle"></i></button>
|
||||
<button type="button" id="search-button">RECHERCHE <i class="bi bi-search"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<main id="content">
|
||||
<!-- Le contenu principal sera injecté ici par le routeur -->
|
||||
</main>
|
||||
|
||||
<footer>
|
||||
<p>© 2024 Archive de Liens. Tous droits réservés.</p>
|
||||
<a href="" id="download-archive">Télécharger l'archive complète</a>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
2
nginx/html/templates/home.html
Normal file
2
nginx/html/templates/home.html
Normal file
@ -0,0 +1,2 @@
|
||||
<h1>Bienvenue sur l'Archive de Liens</h1>
|
||||
<p>Explorez notre collection de sources archivées sur la pandémie de COVID-19 et les vaccins.</p>
|
||||
6
nginx/html/templates/search.html
Normal file
6
nginx/html/templates/search.html
Normal file
@ -0,0 +1,6 @@
|
||||
<h2>Rechercher des sources</h2>
|
||||
<form class="search-form" id="searchForm">
|
||||
<input type="text" placeholder="Mots-clés" required>
|
||||
<button type="submit">Rechercher</button>
|
||||
</form>
|
||||
<div id="searchResults"></div>
|
||||
4
nginx/html/templates/sources.html
Normal file
4
nginx/html/templates/sources.html
Normal file
@ -0,0 +1,4 @@
|
||||
<h2>Sources archivées</h2>
|
||||
<ul class="source-list" id="sourcesList">
|
||||
<!-- Les éléments de la liste seront injectés ici par JavaScript -->
|
||||
</ul>
|
||||
15
nginx/html/templates/suggest.html
Normal file
15
nginx/html/templates/suggest.html
Normal file
@ -0,0 +1,15 @@
|
||||
<h2>Suggérer une source</h2>
|
||||
<form class="suggestion-form" id="suggestionForm">
|
||||
<input type="text" placeholder="Titre" required>
|
||||
<input type="url" placeholder="URL de la source" required>
|
||||
<textarea placeholder="Description" required></textarea>
|
||||
<select required>
|
||||
<option value="">Sélectionner une catégorie</option>
|
||||
<option value="medical">Médical</option>
|
||||
<option value="scientific">Scientifique</option>
|
||||
<option value="political">Politique</option>
|
||||
<option value="economic">Économique</option>
|
||||
<option value="social">Social</option>
|
||||
</select>
|
||||
<button type="submit">Soumettre</button>
|
||||
</form>
|
||||
BIN
nginx/static/404.png
Normal file
BIN
nginx/static/404.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 31 KiB |
BIN
nginx/static/favicon.ico
Normal file
BIN
nginx/static/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.5 MiB |
59
nginx/static/scripts/main.js
Normal file
59
nginx/static/scripts/main.js
Normal file
@ -0,0 +1,59 @@
|
||||
import { initRouter } from './router.js';
|
||||
import { initNavigation } from './navigation.js';
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
initRouter();
|
||||
initNavigation();
|
||||
|
||||
document.getElementById('download-archive').addEventListener('click', (e) => {
|
||||
e.preventDefault();
|
||||
console.log('Téléchargement de l\'archive');
|
||||
});
|
||||
});
|
||||
|
||||
async function loadTemplate(templateName) {
|
||||
const response = await fetch(`/templates/${templateName}.html`);
|
||||
return await response.text();
|
||||
}
|
||||
|
||||
export async function displayHome() {
|
||||
const content = document.getElementById('content');
|
||||
content.innerHTML = await loadTemplate('home');
|
||||
}
|
||||
|
||||
export async function displaySources(sources) {
|
||||
const content = document.getElementById('content');
|
||||
content.innerHTML = await loadTemplate('sources');
|
||||
|
||||
const sourcesList = document.getElementById('sourcesList');
|
||||
sourcesList.innerHTML = sources.map(source => `
|
||||
<li class="source-item">
|
||||
<h3>${source.title}</h3>
|
||||
<p>${source.description}</p>
|
||||
<p class="category">Catégorie: ${source.category}</p>
|
||||
<a href="${source.archiveUrl}" target="_blank">Lien archivé</a>
|
||||
</li>
|
||||
`).join('');
|
||||
}
|
||||
|
||||
export async function displaySuggestionForm() {
|
||||
const content = document.getElementById('content');
|
||||
content.innerHTML = await loadTemplate('suggest');
|
||||
|
||||
document.getElementById('suggestionForm').addEventListener('submit', (e) => {
|
||||
e.preventDefault();
|
||||
// Logique pour traiter la soumission du formulaire
|
||||
console.log('Formulaire de suggestion soumis');
|
||||
});
|
||||
}
|
||||
|
||||
export async function displaySearchForm() {
|
||||
const content = document.getElementById('content');
|
||||
content.innerHTML = await loadTemplate('search');
|
||||
|
||||
document.getElementById('searchForm').addEventListener('submit', (e) => {
|
||||
e.preventDefault();
|
||||
// Logique pour traiter la recherche
|
||||
console.log('Recherche soumise');
|
||||
});
|
||||
}
|
||||
17
nginx/static/scripts/navigation.js
Normal file
17
nginx/static/scripts/navigation.js
Normal file
@ -0,0 +1,17 @@
|
||||
export function initNavigation() {
|
||||
document.getElementById('home-button').addEventListener('click', () => {
|
||||
window.location.hash = '#/';
|
||||
});
|
||||
|
||||
document.getElementById('sources-button').addEventListener('click', () => {
|
||||
window.location.hash = '#/sources';
|
||||
});
|
||||
|
||||
document.getElementById('suggest-button').addEventListener('click', () => {
|
||||
window.location.hash = '#/suggest';
|
||||
});
|
||||
|
||||
document.getElementById('search-button').addEventListener('click', () => {
|
||||
window.location.hash = '#/search';
|
||||
});
|
||||
}
|
||||
26
nginx/static/scripts/router.js
Normal file
26
nginx/static/scripts/router.js
Normal file
@ -0,0 +1,26 @@
|
||||
import { displayHome, displaySources, displaySuggestionForm, displaySearchForm } from './main.js';
|
||||
|
||||
const routes = {
|
||||
'/': displayHome,
|
||||
'/sources': () => {
|
||||
// Simulons des données pour l'exemple
|
||||
const sources = [
|
||||
{ title: 'Source 1', description: 'Description 1', category: 'Médical', archiveUrl: '#' },
|
||||
{ title: 'Source 2', description: 'Description 2', category: 'Scientifique', archiveUrl: '#' },
|
||||
];
|
||||
displaySources(sources);
|
||||
},
|
||||
'/suggest': displaySuggestionForm,
|
||||
'/search': displaySearchForm
|
||||
};
|
||||
|
||||
export function initRouter() {
|
||||
async function router() {
|
||||
const path = window.location.hash.slice(1) || '/';
|
||||
const route = routes[path] || routes['/'];
|
||||
await route();
|
||||
}
|
||||
|
||||
window.addEventListener('hashchange', router);
|
||||
window.addEventListener('load', router);
|
||||
}
|
||||
100
nginx/static/styles/styles.css
Normal file
100
nginx/static/styles/styles.css
Normal file
@ -0,0 +1,100 @@
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
line-height: 1.6;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background-color: #f4f4f4;
|
||||
}
|
||||
|
||||
header {
|
||||
background-color: #333;
|
||||
color: #fff;
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
nav {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
#tabs-list button {
|
||||
background: none;
|
||||
border: none;
|
||||
color: #fff;
|
||||
cursor: pointer;
|
||||
margin-right: 1rem;
|
||||
}
|
||||
|
||||
main {
|
||||
padding: 2rem;
|
||||
}
|
||||
|
||||
footer {
|
||||
background-color: #333;
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
padding: 1rem;
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.source-list {
|
||||
list-style-type: none;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.source-item {
|
||||
background-color: #fff;
|
||||
margin-bottom: 1rem;
|
||||
padding: 1rem;
|
||||
border-radius: 5px;
|
||||
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
.source-item h3 {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.source-item .category {
|
||||
font-style: italic;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.suggestion-form {
|
||||
max-width: 600px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.suggestion-form input,
|
||||
.suggestion-form textarea {
|
||||
width: 100%;
|
||||
padding: 0.5rem;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.suggestion-form button {
|
||||
background-color: #333;
|
||||
color: #fff;
|
||||
border: none;
|
||||
padding: 0.5rem 1rem;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.search-form {
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
.search-form input {
|
||||
width: 70%;
|
||||
padding: 0.5rem;
|
||||
}
|
||||
|
||||
.search-form button {
|
||||
background-color: #333;
|
||||
color: #fff;
|
||||
border: none;
|
||||
padding: 0.5rem 1rem;
|
||||
cursor: pointer;
|
||||
}
|
||||
Reference in New Issue
Block a user