Snippets

litmis Node.js listening on two ports for the purposes of forwarding non-secure traffic to a secure one. Note SSL wasn't included and instead just traffic forwarding concept.

Updated by Andrei Tyuhai

File content.md Modified

  • Ignore whitespace
  • Hide word diff
   |   |   | 
 - | - | - | -
-[![IBM i Hosting](http://bit.ly/2egcCyV)](https://kti.news/bbs-litmis-spaces) | [![Cybersource Toolkit for i](http://bit.ly/2eg6AhY)](https://kti.news/bbs-cti) | [![RPG-XML Suite](http://bit.ly/2eg6A1i)](https://kti.news/bbs-rpgxmlsuite)
- []() | [![RPG-XML Suite](http://bit.ly/2i5TlT4)](https://kti.news/bbs-ptti) | [![UPS Toolkit for i](http://bit.ly/2efuv0P)](https://kti.news/bbs-upsti) 
+[![IBM i Hosting](http://krengel.tech/img_litmis_hosting)](http://krengel.tech/space0cf4) | [![Cybersource Toolkit for i](http://krengel.tech/img_cti)](http://krengel.tech/cyberb788) | [![RPG-XML Suite](http://krengel.tech/img_rxs)](http://krengel.tech/rpgxm7551)
+[]() | [![Payment Terminal Toolkit for i](http://krengel.tech/img_ptti)](http://krengel.tech/payme5f56) | [![UPS Toolkit for i](http://krengel.tech/img_upsti)](http://krengel.tech/upsto60db)
 
 # Node.js Listening On Two Ports
 Node.js listening on two ports for the purposes of forwarding non-secure traffic to a secure one.  Note SSL wasn't included and instead just traffic forwarding concept.
Updated by Aaron Bartell

File content.md Added

  • Ignore whitespace
  • Hide word diff
+  |   |   | 
+- | - | - | -
+[![IBM i Hosting](http://bit.ly/2egcCyV)](https://kti.news/bbs-litmis-spaces) | [![Cybersource Toolkit for i](http://bit.ly/2eg6AhY)](https://kti.news/bbs-cti) | [![RPG-XML Suite](http://bit.ly/2eg6A1i)](https://kti.news/bbs-rpgxmlsuite)
+ []() | [![RPG-XML Suite](http://bit.ly/2i5TlT4)](https://kti.news/bbs-ptti) | [![UPS Toolkit for i](http://bit.ly/2efuv0P)](https://kti.news/bbs-upsti) 
+
+# Node.js Listening On Two Ports
+Node.js listening on two ports for the purposes of forwarding non-secure traffic to a secure one.  Note SSL wasn't included and instead just traffic forwarding concept.
+
+```js
+var http = require('http')
+var os = require('os')
+
+http.createServer(function(req, res) {
+  var new_loc = 'http://' + os.hostname() + ':8443'
+  console.log('new_loc:%s', new_loc)
+  res.writeHead(301,
+    {Location: new_loc}
+  );
+  res.end();
+}).listen(8080);
+
+http.createServer(function(req, res) {
+  console.log('secure')
+  res.writeHead(200, {'Content-Type': 'text/plain'});
+  res.end('Response 8443\n');
+}).listen(8443);
+```

File twoports.js Deleted

  • Ignore whitespace
  • Hide word diff
-var http = require('http')
-var os = require('os')
-
-http.createServer(function(req, res) {
-  var new_loc = 'http://' + os.hostname() + ':8443'
-  console.log('new_loc:%s', new_loc)
-  res.writeHead(301,
-    {Location: new_loc}
-  );
-  res.end();
-}).listen(8080);
-
-http.createServer(function(req, res) {
-  console.log('secure')
-  res.writeHead(200, {'Content-Type': 'text/plain'});
-  res.end('Response 8443\n');
-}).listen(8443);
-
Updated by Aaron Bartell

File twoports.js Modified

  • Ignore whitespace
  • Hide word diff
 var http = require('http')
+var os = require('os')
 
 http.createServer(function(req, res) {
+  var new_loc = 'http://' + os.hostname() + ':8443'
+  console.log('new_loc:%s', new_loc)
   res.writeHead(301,
-    {Location: 'http://' + req.headers.host + ':8443'}
+    {Location: new_loc}
   );
   res.end();
 }).listen(8080);
 
 http.createServer(function(req, res) {
-  res.write('Response 8443\n');
-  res.end();
+  console.log('secure')
+  res.writeHead(200, {'Content-Type': 'text/plain'});
+  res.end('Response 8443\n');
 }).listen(8443);
 
-
-
Created by Aaron Bartell

File twoports.js Added

  • Ignore whitespace
  • Hide word diff
+var http = require('http')
+
+http.createServer(function(req, res) {
+  res.writeHead(301,
+    {Location: 'http://' + req.headers.host + ':8443'}
+  );
+  res.end();
+}).listen(8080);
+
+http.createServer(function(req, res) {
+  res.write('Response 8443\n');
+  res.end();
+}).listen(8443);
+
+
+
HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.