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

389
Views
I can't get nodejs to work on apache when deploying

I've heard it's possible to redirect request from apache to nodejs server with reverse proxy. I tried to do it but it doesn't work. I have a 404 error. Here's my apache config :

<VirtualHost WW.XX.YY.ZZ:80>
    SuexecUserGroup "#1004" "#1004"
    ServerName api.example.com
    ServerAlias www.api.example.com
    ServerAlias mail.api.example.com
    ServerAlias webmail.api.example.com
    ServerAlias admin.api.example.com
    DocumentRoot /home/example/domains/api.example.com/public_html
    ErrorLog /var/log/virtualmin/api.example.com_error_log
    CustomLog /var/log/virtualmin/api.example.com_access_log combined
    ScriptAlias /cgi-bin/ /home/example/domains/api.example.com/cgi-bin/
    ScriptAlias /awstats/ /home/example/domains/api.example.com/cgi-bin/
    DirectoryIndex index.html index.htm index.php index.php4 index.php5
    

ProxyRequests Off
    ProxyPreserveHost On
    ProxyVia Full
    <Proxy *>
    Order deny,allow
    Allow from all
    </Proxy>
   <Location /home/example/domains/api.example.com/public_html>
      ProxyPass http://localhost:8080/
      ProxyPassReverse http://localhost:8080/
   </Location>
</VirtualHost>

And my nodejs server is working locally so I don't think is the problem, but I share it just in case :

const express = require("express");
const cors = require("cors");

const fs = require('fs');
const http = require('http');
const https = require('https');
const privateKey  = fs.readFileSync('./ssl.key', 'utf8');
const certificate = fs.readFileSync('./ssl.cert', 'utf8');

var credentials = {key: privateKey, cert: certificate};
const app = express();

app.use(cors());
app.use(express.json())


require("./routes/wordpress.routes.js")(app);
require("./routes/entries.routes.js")(app);
// set port, listen for requests
var httpServer = http.createServer(app);
var httpsServer = https.createServer(credentials, app);

httpServer.listen(8080);
httpsServer.listen(8443);

What I'm doing wrong ?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Fixed like that :

  ProxyPass "/" "http://localhost:8080/"
  ProxyPassReverse "/" "http://localhost:8080/"
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!