From 52a3afb98a4fd1ef824a869785ce47472c2f1e40 Mon Sep 17 00:00:00 2001 From: Tykayn Date: Mon, 12 Jun 2023 23:33:07 +0200 Subject: [PATCH] fix models --- nginx_config_maker/index.mjs | 5 ++-- nginx_config_maker/model.symfony.mjs | 8 +++--- nginx_config_maker/model.wordpress.mjs | 35 +++++++++++++------------- 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/nginx_config_maker/index.mjs b/nginx_config_maker/index.mjs index 64d3b73e..5068a6c7 100644 --- a/nginx_config_maker/index.mjs +++ b/nginx_config_maker/index.mjs @@ -10,6 +10,7 @@ import { makeHostFileForSymfony } from './model.symfony.mjs' const LXCcontainerLocalIP = '10.10.10.103' const LXCcontainerProtocol = 'https' + const domainsConfig = [{ LXCcontainerLocalIP, LXCcontainerProtocol, @@ -129,8 +130,8 @@ for (let configDomain of domainsConfig) { if (configDomain.framework === 'symfony') { hostFile = makeHostFileForSymfony(configDomain) } - writeFile(configDomain.domain + '.host.conf', hostFile.homeNginxConf) - writeFile(configDomain.domain + '.container.conf', hostFile.containerNginxConf) + writeFile(configDomain.domain + '_host.conf', hostFile.homeNginxConf) + writeFile(configDomain.domain + '_container.conf', hostFile.containerNginxConf) } function writeFile (fileName, fileContent) { diff --git a/nginx_config_maker/model.symfony.mjs b/nginx_config_maker/model.symfony.mjs index a8a1330b..c903d5d9 100644 --- a/nginx_config_maker/model.symfony.mjs +++ b/nginx_config_maker/model.symfony.mjs @@ -35,23 +35,23 @@ server { } `, containerNginxConf : `server { - if ($host = ${domainConfig.name}) { + if ($host = ${domainConfig.domain}) { return 301 https://$host$request_uri; } listen 80 ; listen [::]:80 ; - server_name ${domainConfig.name}; + server_name ${domainConfig.domain}; # enforce https return 301 https://$server_name$request_uri; add_header Permissions-Policy "interest-cohort=()"; - root /home/www/tykayn/${domainConfig.name}/; + root /home/www/tykayn/${domainConfig.domain}/; index index.php index.html; } - +# ========================== ${domainConfig.name} | fin ================ # ` } return model; diff --git a/nginx_config_maker/model.wordpress.mjs b/nginx_config_maker/model.wordpress.mjs index 5dc67a51..daa74d50 100644 --- a/nginx_config_maker/model.wordpress.mjs +++ b/nginx_config_maker/model.wordpress.mjs @@ -22,18 +22,18 @@ export function makeHostFileForWordpress (domainConfig) { server { # redirect to https from http - server_name ${domainConfig.name}; + server_name ${domainConfig.domain}; listen 80 http2; - return 301 https://${domainConfig.name}$request_uri; + return 301 https://${domainConfig.domain}$request_uri; } server { listen 443 ssl http2; listen [::]:443 ssl http2; - server_name ${domainConfig.name}; - ssl_certificate /etc/letsencrypt/live/${domainConfig.name}-0001/fullchain.pem; - ssl_certificate_key /etc/letsencrypt/live/${domainConfig.name}-0001/privkey.pem; + server_name ${domainConfig.domain}; + ssl_certificate /etc/letsencrypt/live/${domainConfig.domain}-0001/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/${domainConfig.domain}-0001/privkey.pem; add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"; location / { proxy_set_header X-Forwarded-For $remote_addr; @@ -48,14 +48,14 @@ server { containerNginxConf: ` # ============ ${domainConfig.name} | côté conteneur LXC =============== server { - if ($host = www.cipherbliss.com) { + if ($host = ${domainConfig.domain}) { return 301 https://$host$request_uri; - } # managed by Certbot + } listen 80 ; listen [::]:80 ; - server_name www.cipherbliss.com; + server_name ${domainConfig.domain}; # enforce https return 301 https://$server_name$request_uri; @@ -63,18 +63,20 @@ server { } + +# ==== https | côté conteneur LXC =============== + server { listen 443 ssl http2; listen [::]:443 ssl http2; - server_name www.cipherbliss.com; + server_name ${domainConfig.domain}; - ssl_certificate /etc/letsencrypt/live/www.cipherbliss.com-0001/fullchain.pem; # managed by Certbot - ssl_certificate_key /etc/letsencrypt/live/www.cipherbliss.com-0001/privkey.pem; # managed by Certbot + ssl_certificate /etc/letsencrypt/live/${domainConfig.domain}-0001/fullchain.pem; # managed by Certbot + ssl_certificate_key /etc/letsencrypt/live/${domainConfig.domain}-0001/privkey.pem; # managed by Certbot - # Path to the root of your installation - root /home/www/tykayn/cipherbliss/; + # Path to the root of your installation + root /home/www/tykayn/${domainConfig.domain}/; - ## This should be in your http block and if it is, it's not needed here. index index.php; location = /favicon.ico { @@ -104,10 +106,9 @@ server { expires max; log_not_found off; } - add_header Permissions-Policy "interest-cohort=()"; + add_header Permissions-Policy "interest-cohort=()"; } - - +# ========================== ${domainConfig.name} | fin ================ # ` } return model