Reputation: 1623
If I create and HTTP server using nodejs like this:
var http = require("http");
http.createServer(function (request, response) {
// Send the HTTP header
// HTTP Status: 200 : OK
// Content Type: text/plain
response.writeHead(200, {'Content-Type': 'text/plain'});
// Send the response body as "Hello World"
response.end('Hello World\n');
}).listen(8081);
// Console will print the message
console.log('Server running at http://127.0.0.1:8081/');
does it mean that if I use a web hosting service, the URL of the website will always need to contain somehow 8081 port? How would the URL look like?
Upvotes: 0
Views: 668
Reputation: 2180
If you expose a server using port 80 means http and / or via 443 means https. Your urls don't need port. Other than that if you are using a different port then you can use ngnix or haproxy to expose them in 80 or 443. Without following this you will end up giving port to the urls
Upvotes: 1
Reputation: 5890
Yes you would always need to the port number with requests, however if you use relative links this will not be such a problem.
<a href="/foo">Good idea</a>
<a href="http://yousite.com:8081">Questionable idea</a>
You may also look into reverse proxies and virtual hosts depending on your application.
Upvotes: 1