@cocreate/nginx
Advanced tools
Comparing version 1.1.2 to 1.1.3
@@ -0,1 +1,8 @@ | ||
## [1.1.3](https://github.com/CoCreate-app/CoCreate-nginx/compare/v1.1.2...v1.1.3) (2024-01-01) | ||
### Bug Fixes | ||
* relocated main nginx config to init ([44c4545](https://github.com/CoCreate-app/CoCreate-nginx/commit/44c454511bf9f1c9ef8a003e5a331aa219116019)) | ||
## [1.1.2](https://github.com/CoCreate-app/CoCreate-nginx/compare/v1.1.1...v1.1.2) (2024-01-01) | ||
@@ -2,0 +9,0 @@ |
{ | ||
"name": "@cocreate/nginx", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"description": "An intergration with Nginx and CoCreateJS.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -63,33 +63,2 @@ const util = require('node:util'); | ||
if (!fs.existsSync(`${enabled}main`)) { | ||
let main = `server { | ||
listen 80 default_server; | ||
listen [::]:80 default_server; | ||
server_name _; | ||
return 301 https://$host$request_uri; | ||
}` | ||
fs.writeFileSync(`${available}main`, main) | ||
await exec(`sudo ln -s ${available}main ${enabled}`); | ||
if (fs.existsSync(`${enabled}default`)) | ||
fs.unlinkSync(`${enabled}default`) | ||
if (fs.existsSync(`${available}default`)) | ||
fs.unlinkSync(`${available}default`) | ||
let test = await exec(`sudo nginx -t`); | ||
if (test.stderr.includes('test is successful')) { | ||
await exec(`sudo systemctl reload nginx`); | ||
console.log('main test passed reloading nginx') | ||
response['main'] = true | ||
} else { | ||
console.log('main test failed') | ||
response['main'] = false | ||
} | ||
} | ||
return response | ||
@@ -143,2 +112,48 @@ } | ||
await exec('sudo chmod 777 /etc/nginx/sites-available'); | ||
await exec('sudo chmod 777 /etc/nginx/sites-enabled'); | ||
if (!fs.existsSync(`${enabled}main`)) { | ||
// let main = `server { | ||
// listen 80 default_server; | ||
// listen [::]:80 default_server; | ||
// server_name _; | ||
// }` | ||
let main = `server { | ||
listen 80 default_server; | ||
listen [::]:80 default_server; | ||
server_name _; | ||
location / { | ||
proxy_pass http://localhost:3000; # Forward traffic to your app on port 3000 | ||
proxy_set_header Host $host; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Forwarded-Proto $scheme; | ||
proxy_set_header Upgrade $http_upgrade; | ||
proxy_set_header Connection "Upgrade"; | ||
} | ||
}` | ||
fs.writeFileSync(`${available}main`, main) | ||
await exec(`sudo ln -s ${available}main ${enabled}`); | ||
if (fs.existsSync(`${enabled}default`)) | ||
fs.unlinkSync(`${enabled}default`) | ||
if (fs.existsSync(`${available}default`)) | ||
fs.unlinkSync(`${available}default`) | ||
let test = await exec(`sudo nginx -t`); | ||
if (test.stderr.includes('test is successful')) { | ||
await exec(`sudo systemctl reload nginx`); | ||
console.log('main test passed reloading nginx') | ||
response['main'] = true | ||
} else { | ||
console.log('main test failed') | ||
response['main'] = false | ||
} | ||
} | ||
} else if (platform === 'darwin') { | ||
@@ -157,3 +172,3 @@ // TODO: For macOS | ||
} catch (error) { | ||
console.error('Failed to Nginx:', error); | ||
console.error('Failed to Nginx:'); | ||
} | ||
@@ -199,4 +214,2 @@ } | ||
init(); | ||
@@ -203,0 +216,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44429
302