404 Not Found nginx/1.18.0 (Ubuntu)

Mahdi Ayyad

I created a website using Express.js and I'm trying to show it on my domain using Nginx but It says 404 not found here's my configuration on my /etc/nginx/sites-available/manucompany.com I have the certificate installed and everything but I don't know the reason why it shows a 404 message. Note that I use PositiveSSL from namecheap

server {
        listen 80;

        server_name manucompany.com www.manucompany.com;

        return 301 https://www.manucompany.com$request_uri;

        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;
        location / {
        root /var/www/manucompany/app.js;
        proxy_pass http://localhost:3001;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
        }
}

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name manucompany.com www.manucompany.com;
        location / {
          root /var/www/manucompany/app.js;
        }
    ssl_certificate /etc/nginx/ssl/manucompany_chain.crt;
    ssl_certificate_key /etc/nginx/ssl/manucompany.key;
    ssl_session_timeout 1d;
    ssl_session_cache shared:MozSSL:10m;  # about 40000 sessions
    ssl_session_tickets off;

    # modern configuration
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:D>
    ssl_prefer_server_ciphers on;

    # HSTS (ngx_http_headers_module is required) (63072000 seconds)
    add_header Strict-Transport-Security "max-age=63072000" always;

   resolver 8.8.8.8;
}

app.js

const express = require('express');
const bodyParser = require('body-parser');  
const exphbs = require('express-handlebars');
const nodemailer = require('nodemailer');
const app = express();
const https = require('https');
const http = require('http');
const path = require('path');
const fs = require('fs');
const hostname = 'manucompany.com';
const expressLayouts = require('express-ejs-layouts');
const port = 3001;

// Static Files 
app.use(express.static('content'));
app.use(express.static(path.join(__dirname + '/content/')));
app.use(express.json());

// Set Views
app.set('views', [__dirname + '/views/', __dirname + '/views/en', __dirname + '/views/tr', __dirname + '/views/ar', __dirname + '/views/en/product', __dirname + '/views/en/product/mercedes', __dirname + '/views/tr/urun', __dirname + '/views/tr/urun/mercedes-tr', __dirname + '/views/ar/el-muntec', __dirname + '/views/ar/el-muntec/mercedes-ar']);
app.set('view engine', 'ejs');

// Body parser middleware 
app.use(bodyParser.urlencoded({extended: false}));
app.use(bodyParser.json());


app.get('/', (req, res) => res.render('index'));
// english page
app.get("/en", (req, res) => res.render("en"));

// turkish page
app.get("/tr", (req, res) => res.render("tr"));

// arabic page
app.get("/ar", (req, res) => res.render("ar"));

app.listen(port, (req,res) => {
    console.log(`Server running on port ${port}`);
})
cbr

Move the proxy_* directives into the server block which has listen 443.

Currently they're in the HTTP server block, but it already does a redirect to the HTTPS port.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related