I have an expressjs server for my website. During development, it worked perfectly and while in deployment, I tried changing to default port 443 to get rid of the port in the url. However, this results in the domain not resolving at all. Even requests directly to the ip do not work. I am using an https server. Changing the port to basically anything else (that is allowed) works perfectly. Even specifying port 80 works (as the server is https and 80 is only for http). I cant seem to get my head around the problem.
Here is the server side code
const express = require('express');
const router = express.Router();
const app = express();
const models = require('./models');
const https = require('https');
const fs = require('fs');
const key = fs.readFileSync('path/to/key'); // From 'letsencrypt'
const cert = fs.readFileSync('path/to/chain'); // From 'letsencrypt'
const options = {
key: key,
cert: cert
};
router.get('/', (req,res) => {
res.send('No Route Found');
generate_log(req)
});
var server = https.createServer(options, app);
app.use('/', router);
const port = 80
server.listen(port, () => {
console.log(`server starting on port : ${port}`)
});
Any help would be greatly appreciated. Thanks. P.S. the firewall is configured correctly.
Edit
What I mean when Isay not resolving is that it takes forever to figure out that there is a problem. Specifically server not found. This only happens when I use 'https://my_site.io' to use the default 443 port. It works when the server is spun up on maybe port 8080 or even 80 'https://my_site.io:80'. This implies that it is rather a configuration error by me in ubuntu and not in the code itself.