diff --git a/pages/api/generate.ts b/pages/api/generate.ts
index 52593d6..5d2fe70 100644
--- a/pages/api/generate.ts
+++ b/pages/api/generate.ts
@@ -3,7 +3,7 @@ import { promises as fs } from 'fs';
import { NextApiRequest, NextApiResponse } from 'next'
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
- var { webServer, sourcePath, domainName, includeWWW } = req.query;
+ var { webServer, sourcePath, domainName, includeWWW, includeSSL } = req.query;
// When a parameter is defined twice, use the first one.
// This keeps the variables as strings instead of arrays if they are defined more than once.
@@ -18,6 +18,13 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
WWW = (includeWWW == 'false') ? false : true;
}
+ if (Array.isArray(includeSSL)){
+ var SSL = (includeSSL[0] == 'false') ? false : true;
+ } else {
+ SSL = (includeSSL == 'false') ? false : true;
+ }
+
+
const templateDirectory = path.join(process.cwd(), 'templates');
const supportedWebServers = ['nginx'];
@@ -25,10 +32,14 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
res.status(400).send('Invalid web server. Accepted values are: ' + supportedWebServers.join(', '));
return;
}
+
+ if(SSL){
+ var template = await fs.readFile(templateDirectory + `/${webServer}.ssl.conf`, 'utf8');
+ }else{
+ var template = await fs.readFile(templateDirectory + `/${webServer}.conf`, 'utf8');
- // Read the template file
- var template = await fs.readFile(templateDirectory + `/${webServer}.conf`, 'utf8');
-
+ }
+
// Some server-specific replacements
switch (webServer) {
case "nginx":
diff --git a/pages/index.tsx b/pages/index.tsx
index d128ee7..260a663 100644
--- a/pages/index.tsx
+++ b/pages/index.tsx
@@ -12,12 +12,14 @@ const Index = () => {
const [sourcePath, setSourcePath] = useState("/var/www/fossbilling.org/src");
const [domainName, setDomainName] = useState("fossbilling.org");
const [includeWWW, setIncludeWWW] = useState(true);
+ const [includeSSL, setIncludeSSL] = useState(true);
+
const [conf, setConf] = useState("");
const [err, setErr] = useState("");
const callTheAPI = async () => {
try {
- const res = await fetch(`/api/generate?webServer=${webServer}&sourcePath=${sourcePath}&domainName=${domainName}&includeWWW=${includeWWW}`);
+ const res = await fetch(`/api/generate?webServer=${webServer}&sourcePath=${sourcePath}&domainName=${domainName}&includeWWW=${includeWWW}&includeSSL=${includeSSL}`);
const data = await res.text();
if (res.ok) {
setConf(data)
@@ -93,6 +95,12 @@ const Index = () => {