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

401
Views
Ngrok > Nginx > localhost ports

I have two node servers running on ports 3000 and 4000. If I had NGINX running and pointed ngrok at it, is there a way I can redirect requests from ngrok subfolders to each node server? eg abc123.nrgok.io/a goes to port 3000, abc123.ngrok.io/b goes to port 4000. There are several routes for each node server and some static html files too.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

In the end I scrapped NGINX and instead ran a third node server which just had http-proxy-middleware running. That seemed to work much better but I did need to change the links in both apps to point at the sub folder and then rewrite the head in the new Node server (eg all the links went from style.css to /serverOne/style.css and then the proxy middleware strips off the /serverOne bit). Code below for the third Node server.

const http = require('http'),
    express = require('express'),
    { createProxyMiddleware } = require('http-proxy-middleware')
const app = express()

app.use('/serverOne', createProxyMiddleware({target:'http://localhost:4000', changeOrigin: true, pathRewrite: {'^/serverOne' : '/'}}))
app.use('/serverTwo', createProxyMiddleware({target:'http://localhost:3000', changeOrigin: true, pathRewrite: {'^/serverTwo' : '/'}))

app.listen(2000);
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!