Browse Source

First module exported

pull/1/head
Muthu Kumar 7 years ago
parent
commit
99136954bb
  1. 46
      actions/createProxyServer.js
  2. 3
      index.js

46
actions/createProxyServer.js

@ -1,23 +1,23 @@
var fs = require('fs-extra')
var domain = domain
var port = port
fs.outputFileSync("/test.txt",
"server {" + "\n" +
" listen 80;" + "\n" +
" listen [::]:80;" + "\n" +
" root /var/www/" + domain + ";" + "\n" +
" index index.html index.htm;" + "\n" +
"" + "\n" +
" server_name " + domain + "\n" +
" location / {" + "\n" +
" proxy_pass http://localhost:" + port + ";" + "\n" +
" proxy_http_version 1.1;" + "\n" +
" proxy_set_header Upgrade $http_upgrade;" + "\n" +
" proxy_set_header Connection 'upgrade';" + "\n" +
" proxy_set_header Host $host;" + "\n" +
" proxy_cache_bypass $http_upgrade;" + "\n" +
"}"
)
console.log('Done')
var fs = require('fs-extra')
function createProxyServer(domain, port) {
fs.outputFileSync("/test.txt",
"server {" + "\n" +
" listen 80;" + "\n" +
" listen [::]:80;" + "\n" +
" root /var/www/" + domain + ";" + "\n" +
" index index.html index.htm;" + "\n" +
"" + "\n" +
" server_name " + domain + "\n" +
" location / {" + "\n" +
" proxy_pass http://localhost:" + port + ";" + "\n" +
" proxy_http_version 1.1;" + "\n" +
" proxy_set_header Upgrade $http_upgrade;" + "\n" +
" proxy_set_header Connection 'upgrade';" + "\n" +
" proxy_set_header Host $host;" + "\n" +
" proxy_cache_bypass $http_upgrade;" + "\n" +
"}"
)
}
module.exports = createProxyServer

3
index.js

@ -41,12 +41,13 @@ program
.action(function(domain, port) {
if(!isFQDN(domain))
console.log('\nDomain is not valid. Please use a valid domain name.')
else if(typeof port != 'number')
else if(typeof port !== 'number')
console.log('\nPort should be a number.')
// Stuff happens here
//test stuff will be deleted later:
else
createProxyServer(domain, port)
console.log('Done!')
//test stuff ends here
})

Loading…
Cancel
Save