73 lines
2.3 KiB
Nginx Configuration File
73 lines
2.3 KiB
Nginx Configuration File
worker_processes 1;
|
|
|
|
events {
|
|
worker_connections 1024;
|
|
}
|
|
|
|
http {
|
|
include /etc/nginx/mime.types;
|
|
default_type application/octet-stream;
|
|
|
|
sendfile on;
|
|
keepalive_timeout 65;
|
|
|
|
access_log /proc/1/fd/1;
|
|
error_log /proc/1/fd/2;
|
|
|
|
server {
|
|
listen 9080;
|
|
server_name localhost;
|
|
|
|
client_max_body_size 10M;
|
|
|
|
# Headers de base
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
proxy_set_header X-Forwarded-Host $host;
|
|
proxy_set_header X-Forwarded-Port $server_port;
|
|
|
|
# Désactiver le buffering
|
|
proxy_buffering off;
|
|
|
|
# Proxy vers CookCLI
|
|
location / {
|
|
proxy_pass http://127.0.0.1:9081;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection "upgrade";
|
|
|
|
# --- RÉÉCRITURE DES URLs POUR L'INGRESS ---
|
|
# Capture le chemin Ingress depuis les headers
|
|
set $ingress_path $http_x_forwarded_prefix;
|
|
if ($ingress_path = "") {
|
|
set $ingress_path "";
|
|
}
|
|
|
|
# Sub_filter pour réécrire les URLs absolues
|
|
sub_filter_once off;
|
|
sub_filter_types text/html text/css application/javascript;
|
|
|
|
# Réécriture des URLs de base
|
|
sub_filter 'href="/' 'href="$ingress_path/';
|
|
sub_filter 'src="/' 'src="$ingress_path/';
|
|
sub_filter 'action="/' 'action="$ingress_path/';
|
|
|
|
# Réécriture spécifique pour les chemins courants
|
|
sub_filter '"/static/' '"$ingress_path/static/';
|
|
sub_filter '"/assets/' '"$ingress_path/assets/';
|
|
sub_filter '"/css/' '"$ingress_path/css/';
|
|
sub_filter '"/js/' '"$ingress_path/js/';
|
|
|
|
# Si l'application utilise des chemins relatifs, les forcer
|
|
sub_filter '<base href="/"' '<base href="$ingress_path/"';
|
|
|
|
# Gérer les redirections
|
|
proxy_redirect http://127.0.0.1:9081/ $scheme://$host$ingress_path/;
|
|
proxy_redirect http://127.0.0.1:9081 $scheme://$host$ingress_path;
|
|
}
|
|
}
|
|
}
|
|
|