51 lines
1.6 KiB
JavaScript
51 lines
1.6 KiB
JavaScript
|
/**
|
||
|
* 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 makeHostFileForWordpress(domainConfig){
|
||
|
|
||
|
/**
|
||
|
* example:
|
||
|
* # redirect to https+www without www from https
|
||
|
* server {
|
||
|
listen 443 http2;
|
||
|
listen [::]:443 http2;
|
||
|
server_name ${domainConfig.name};
|
||
|
return 301 https://${domainConfig.name}$request_uri;
|
||
|
}
|
||
|
* @type {{homeNginxConf: string, containerNginxConf: string}}
|
||
|
*/
|
||
|
const model = {
|
||
|
homeNginxConf: `
|
||
|
# ============ ${domainConfig.name} ===============
|
||
|
|
||
|
server {
|
||
|
# redirect to https from http
|
||
|
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};
|
||
|
ssl_certificate /etc/letsencrypt/live/${domainConfig.name}-0001/fullchain.pem;
|
||
|
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;
|
||
|
# Container tksites
|
||
|
proxy_pass ${domainConfig.LXCcontainerProtocol}://${domainConfig.LXCcontainerLocalIP};
|
||
|
}
|
||
|
|
||
|
add_header Permissions-Policy "interest-cohort=()";
|
||
|
}
|
||
|
`,
|
||
|
containerNginxConf: ``
|
||
|
}
|
||
|
return model
|
||
|
}
|