Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

639
Views
How to run a express server using nginx in localhost?

I want to run the express server using Nginx in localhost. Is it possible? If it is possible how can I achieve that?

const express = require('express')
const app = express()
const port = 3000

app.get('/', (req, res) => res.send('Hello World!'))

app.listen(port, () => console.log(`Server listening at http://localhost:${port}`))
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

If you want to use nginx as a reverse proxy for express you can configure your server as follow:

server {
    listen 80 default_server;
    server_name _;

location / {
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_pass http://localhost:3000; #port where you are serving your express app.

  }
}

You should make your configuration in /etc/nginx/sites-available/default

After change the configuration file, check if there is no error in your script:

$sudo nginx -t

Expected result should be:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

After configuration is ok, you should restart your nginx instance, with command:

$sudo nginx -s reload

After proper reload assert your node/express server is running. Now if you access http://localhost you should see what's is listening in http://localhost:3000

Nginx should be serving your instance, when you stop your nodes / express you should see default error 502.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!