Ad

How To Remove Port Number 8080 From My Domain Name Using Nginx V1.14.1?

- 1 answer

I am using node and express, AWS Ec2 Linux and running two web apps in port number 8080 and 8081 using pm2.

added subdomains to my Elastic IP admin.example.com and app.example.com.

My both app running in localhost:8080 and 8081.

/etc/nginx/conf.d/virtual.conf // After Edit

server {
    listen   admin.example.com:80;
    server_name  admin.example.com;
    location / {
        proxy_pass http://localhost:8080;
    }
}

/etc/nginx/conf.d/virtual.conf // Before Edit

#
# A virtual host using mix of IP-, name-, and port-based configuration
#

#server {
#    listen   8000;
#    listen   somename:8080;
#    server_name  somename  alias  another.alias;

#    location / {
#        root   html;
#        index  index.html index.htm;
#    }
#}

server.js

const express = require('express');
const bodyParser = require('body-parser')
const path = require('path');
const app = express();
app.use(express.static(path.join(__dirname, 'build')));

app.get('/login', function (req, res) {
    res.sendFile(path.join(__dirname, 'build', 'index.html'));
});

app.get('/logout', function (req, res) {
    res.sendFile(path.join(__dirname, 'build', 'index.html'));
});

app.listen('8080');
console.log('Server started at port 8080');

nginx running fine after the restart but did not remove port number 8080 from my domain.

What are the things to be done with port 80?, I just enabled 80 from my AWS Instance inbound rule, Anything else I miss?

Ad

Answer

Issues Fixed :

Inbound rules added only ::/0 in the source for port 80, after remove and add HTTP, source updated like 0.0.0.0/0, ::/0 now all runs fine.

Ad
source: stackoverflow.com
Ad