2023-06-12 23:13:15 +02:00
|
|
|
|
/**
|
|
|
|
|
* 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 = {
|
2023-06-27 13:22:03 +02:00
|
|
|
|
noContainerNginxConf: ``,
|
2023-06-12 23:13:15 +02:00
|
|
|
|
homeNginxConf : `
|
|
|
|
|
# ---------------- ${domainConfig.name} -------------------------
|
2023-06-12 23:41:37 +02:00
|
|
|
|
# ---------- un site utilisant Symfony --------------------------
|
2023-06-12 23:13:15 +02:00
|
|
|
|
|
|
|
|
|
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=()";
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
`,
|
2023-06-12 23:27:17 +02:00
|
|
|
|
containerNginxConf : `server {
|
2023-06-12 23:33:07 +02:00
|
|
|
|
if ($host = ${domainConfig.domain}) {
|
2023-06-12 23:27:17 +02:00
|
|
|
|
return 301 https://$host$request_uri;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
listen 80 ;
|
|
|
|
|
listen [::]:80 ;
|
2023-06-12 23:33:07 +02:00
|
|
|
|
server_name ${domainConfig.domain};
|
2023-06-12 23:27:17 +02:00
|
|
|
|
# enforce https
|
|
|
|
|
return 301 https://$server_name$request_uri;
|
|
|
|
|
|
|
|
|
|
add_header Permissions-Policy "interest-cohort=()";
|
2023-06-12 23:33:07 +02:00
|
|
|
|
root /home/www/tykayn/${domainConfig.domain}/;
|
2023-06-12 23:27:17 +02:00
|
|
|
|
index index.php index.html;
|
|
|
|
|
|
|
|
|
|
}
|
2023-06-12 23:33:07 +02:00
|
|
|
|
# ========================== ${domainConfig.name} | fin ================ #
|
2023-06-12 23:27:17 +02:00
|
|
|
|
`
|
2023-06-12 23:13:15 +02:00
|
|
|
|
}
|
|
|
|
|
return model;
|
|
|
|
|
}
|