scripts/nginx_config_maker/model.symfony.mjs
2023-06-12 23:41:37 +02:00

59 lines
1.8 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* turns a domain config to two config files for nginx web sever on proxmox and its container
* @param domainConfig
* @returns {{homeNginxConf: string, containerNginxConf: string}}
*/
export function makeHostFileForSymfony(domainConfig){
const model = {
homeNginxConf : `
# ---------------- ${domainConfig.name} -------------------------
# ---------- un site utilisant Symfony --------------------------
server {
server_name ${domainConfig.name};
listen 80 http2;
return 301 https://${domainConfig.name}$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name ${domainConfig.name};
${domainConfig.disableSSL ? '#' : ''} ssl_certificate /etc/letsencrypt/live/${domainConfig.name}-0001/fullchain.pem;
${domainConfig.disableSSL ? '#' : ''} ssl_certificate_key /etc/letsencrypt/live/${domainConfig.name}-0001/privkey.pem;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload";
location / {
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $http_host;
# redirection to containter
proxy_pass http://${domainConfig.LXCcontainerLocalIP};
}
add_header Permissions-Policy "interest-cohort=()";
}
`,
containerNginxConf : `server {
if ($host = ${domainConfig.domain}) {
return 301 https://$host$request_uri;
}
listen 80 ;
listen [::]:80 ;
server_name ${domainConfig.domain};
# enforce https
return 301 https://$server_name$request_uri;
add_header Permissions-Policy "interest-cohort=()";
root /home/www/tykayn/${domainConfig.domain}/;
index index.php index.html;
}
# ========================== ${domainConfig.name} | fin ================ #
`
}
return model;
}