diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..b58b603 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,5 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/NginxInstaller.iml b/.idea/NginxInstaller.iml new file mode 100644 index 0000000..24643cc --- /dev/null +++ b/.idea/NginxInstaller.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..1ce9778 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,21 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..85dfdbd --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/app.js b/app.js new file mode 100644 index 0000000..56a1065 --- /dev/null +++ b/app.js @@ -0,0 +1,82 @@ +document.getElementById("submit").addEventListener("click", generateQuickCmd, false); + +const service = "[Unit]\n" + + "Description=The NGINX HTTP and reverse proxy server\n" + + "After=syslog.target network-online.target remote-fs.target nss-lookup.target\n" + + "Wants=network-online.target\n" + + "\n" + + "[Service]\n" + + "Type=forking\n" + + "PIDFile=/var/run/nginx.pid\n" + + "ExecStartPre=/usr/sbin/nginx -t\n" + + "ExecStart=/usr/sbin/nginx\n" + + "ExecReload=/usr/sbin/nginx -s reload\n" + + "ExecStop=/bin/kill -s QUIT $MAINPID\n" + + "PrivateTmp=true\n" + + "\n" + + "[Install]\n" + + "WantedBy=multi-user.target"; + +function generateQuickCmd() { + fetch("https://paste.nevets.tech/api/", { + method: "POST", + headers: {'Content-Type': 'application/json'}, + body: "{'format':'url','content':'" + buildCmd() + "','expires':3600,'lexer':'bash'}" + }).then(res => res.json().then(json => { + document.getElementById("script").innerText = "curl -s " + json.url + "/raw | bash"; + })); +} + +function buildCmd() { + let nginxStr = document.getElementById("link").value; //https://nginx.org/download/nginx-x.xx.x.tar.gz + + let script = "#!/bin/bash\n" + + "if [ \"$EUID\" -ne 0 ]\n" + + " then echo \"Please run as root (or with sudo)\"\n" + + " exit\n" + + "fi\n\n" + + "apt install build-essential libpcre3 libpcre3-dev zlib1g zlib1g-dev libssl-dev\n" + + "wget " + document.getElementById("link").value + "\n" + + "tar -xzvf " + extractNginxVersion(nginxStr) + "\n"; + if (document.getElementById("extMod").checked === true) { + script += "git clone https://github.com/google/ngx_brotli.git\n" + + "git clone https://github.com/openresty/headers-more-nginx-module.git\n" + + "cd ngx_brotli/ && git submodule update --init && cd ../" + extractNginxVersion(nginxStr).replace(/\.tar\.gz$/, '') + "/\n"; + } else { + script += "cd " + extractNginxVersion(nginxStr).replace(/\.tar\.gz$/, '') + "\n"; + } + script += "cp -r conf /etc/nginx\n" + + "mkdir /var/cache/nginx && sudo chown www-data:www-data /var/cache/nginx" + + getConfigureStr() + "\n" + + "make\n" + + "make install\n" + + "echo \"" + service + "\" >> /lib/systemd/system/nginx.service\n" + + "systemctl enable nginx.service\n" + + "systemctl start nginx.service"; + + return script; +} + +function getConfigureStr() { + let str = "./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/etc/nginx/logs/error.log --http-log-path=/etc/nginx/logs/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=www-data --group=www-data "; + if (document.getElementById("extMod").checked === true) { + str += "--add-module=../headers-more-nginx-module --add-module=../ngx_brotli "; + } + if (document.getElementById("http3").checked === true) { + str += "--with-http_v3_module "; + } + str += "--with-file-aio --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_auth_request_module --with-http_gunzip_module --with-http_gzip_static_module "; + + return str; +} + +function extractNginxVersion(url) { + // This regex matches 'nginx' followed by a hyphen and a version number, followed by '.tar.gz' + const regex = /nginx-\d+\.\d+\.\d+\.tar\.gz/; + + // Use the regex to search the string + const match = url.match(regex); + + // If a match is found, return it. Otherwise, return null or an appropriate message + return match ? match[0] : null; +} \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 0000000..5fd3f25 --- /dev/null +++ b/index.html @@ -0,0 +1,35 @@ + + + + + Nginx Installer + + + +
+ + + + + + +
+ + + + diff --git a/style.css b/style.css new file mode 100644 index 0000000..1329f1b --- /dev/null +++ b/style.css @@ -0,0 +1,86 @@ +body { + margin: 0; + height: 100vh; + display: flex; + justify-content: center; + align-items: center; + background-color: #f0f0f0; + font-family: "Arial Rounded MT Bold", serif; +} + +.main { + display: flex; + flex-direction: column; + align-items: flex-start; + padding: 20px; + background-color: #fff; + box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); + border-radius: 10px; + width: fit-content; /* Adjust the width to fit the content */ +} + +label { + display: flex; + align-items: center; /* Align label text with checkbox */ + margin: 10px 0; + position: relative; + cursor: pointer; +} + +/* Adjust the spacing specifically for the first label */ +label:first-child { + margin-bottom: 20px; /* Increase spacing below the first label */ + width: 80%; +} + +input[type="text"] { + margin-bottom: 10px; /* Adds margin below the text input */ + width: 100%; /* Full width of its parent */ + box-sizing: border-box; /* Include padding and border in the element's total width */ +} + +/* Style for checkboxes */ +input[type="checkbox"] { + margin-right: 10px; /* Space between checkbox and label text */ +} + +/* Styling for links */ +a { + color: blue; + text-decoration: none; +} + +a:hover { + text-decoration: underline; +} + +/* General button styling */ +button { + padding: 10px 20px; + font-size: 16px; + color: white; + background-color: #007bff; + border: none; + border-radius: 5px; + cursor: pointer; + outline: none; + transition: background-color 0.3s ease; +} + +button:hover { + background-color: #0056b3; +} + +button:active { + box-shadow: + 7px 6px 28px 1px rgba(0, 0, 0, 0.24); + transform: translateY(4px); + /* Moving button 4px to y-axis */ +} + +/* Class to center the button in the container */ +.centered-button { + display: block; + margin: 20px auto; /* Adds 20px space above and centers horizontally */ + width: fit-content; /* Auto width to fit the button's content */ +} \ No newline at end of file