Requests sent to the Nodejs backend server are not forwarded by Apache

After trying numerous configurations in my vhost.conf file to set up proxying without success, I am seeking help. I have a nodejs backend server running on port 3000, but despite my efforts, I can't seem to forward requests to it properly. When I remove any vhost configuration and access the server using its IP address, everything works fine. However, as soon as I add any vhost.conf settings, I get a "Service Unavailable" message in the browser. Can anyone offer assistance? Thank you. Below is the content of my vhost.conf file. I'm not using a domain name, just the server's IP address for incoming requests.

<VirtualHost *:80>
    
    ServerName localhost

    ProxyPreserveHost On
    ProxyRequests Off

    ProxyPass / http://localhost:3000/
    ProxyPassReverse / http://localhost:3000/

</VirtualHost>

Answer №1

After setting up numerous servers without the need for

<IfModule mod_proxy.c></ifModule>
tags, I encountered an odd problem where adding these tags was necessary to make it work on a new server setup. It took me a whole day of troubleshooting to realize this simple solution.

 <VirtualHost *:80>

    ServerName localhost

    <IfModule mod_proxy.c>
     ProxyPass / http://localhost:3000/ retry=0 timeout=5
     ProxyPassReverse / http://localhost:3000/
    </IfModule>

 </VirtualHost>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Error connecting to the database occurred due to a network issue with Mongodb on the initial attempt

I am attempting to establish a connection to mongodb atlas but encountering an issue. MongoNetworkError: failed to connect to server [accounting-shard-00-01-6tg4q.mongodb.net:27017] on first connect [MongoNetworkError: connection timed out] mongoose .c ...

After downloading Node.js version 14.4 from the website and installing it, I discovered that the Command Prompt still registers the older version 8.10

Need some help updating Node.js and npm. I've been using Node.js version 8.10.0 and npm version 3.5.2 for a while, but realized that there are newer versions available. I downloaded the latest Node.js version and added the path to Environment Variable ...

The function `socket.broadcast.to(roomId).emit('xxxxxx', data)` is not functioning as expected on the client side

Frontend code: var app = angular.module("chatApp", ['btford.socket-io']); app.factory('socket', function (socketFactory) { return socketFactory({ prefix: '', ioSocket: io.connect(&ap ...

Make sure Node.js is flushing writes to child processes

To initiate a child process, I use the following code snippet: var child = require('child_process'); var proc = child.spawn('python', ['my_script.py', '-p', 'example']); In addition, I configure data hand ...

When utilizing `npm install --save`, it is important to understand the significance of saving the installed

Although I grasp the distinctions between npm install something and npm install something --save (just to clarify, the former only installs the dependency while the latter also adds it to your package.json), I find myself puzzled by the existence of the -- ...

gulp-open not functioning properly following the use of createWriteStream

I am utilizing gulp, gulp-eslint, and gulp-open to generate a report detailing ESLint outcomes. The linting and file creation processes function correctly; however, the task aimed at opening the file containing my report encounters issues. gulp.task(&apos ...

Verify the presence of a GET parameter in the URL

Working on a simple log in form for my website using Jade and ExpressJS. Everything is functioning correctly, except for one issue - handling incorrect log in details. When users input wrong information, they are redirected back to the log in page with a p ...

Error message 'Token not found' received after attempting to process payment through Stripe

I am in the process of setting up payment functionality using the Stripe API on an iPad. The goal is to allow users to log into their Stripe account and accept payments from others. To achieve this, I am utilizing Stripe Connect for authentication and savi ...

Issue: Implementing Create, Read, Update, and Delete operations with Node.js,

I encountered an issue with my project while attempting to implement CRUD operations using MVC. The code runs without returning any data from the database, even though the connection seems to be working fine. I am utilizing NodeJS Express and MySQL for thi ...

Move the location of the npm-debug.log file

Whenever I initiate npm start and encounter an error, the following message is displayed: npm ERR! Additional logging details can be found in: npm ERR! /home/hsz/Projects/project/npm-debug.log npm ERR! not ok code 0 This file is located within the di ...

Execute the node server and webpack simultaneously by utilizing the package.json file

I recently finished a todo app project after following along with this informative video: Excellent MEAN Stack Tutorial: Angular, Node/Express, Webpack, MongoDB, SASS, Babel/ES6, Bootstrap In the tutorial, specifically at minute 19:18 on this link, the i ...

Unexpected behavior observed with Async Await

I'm currently working on a feature for my node server that involves using cheerio to extract information from a website. However, I'm facing some unexpected behavior with my functions. Here is the controller code: class ScraperController { s ...

React Native is unable to locate node and npm

https://i.stack.imgur.com/0jd8e.png Currently working on developing a fresh react-native application, encountering a particular error. Confirmed that Node and npm are both properly installed, with the PATH set accordingly. ...

Retrieve the specific object from the array filter using Mongoose

My mongodb data structure is set up like this {_id:ObjectId(''), "awards" : [ { "award" : "Ballon d'Or", "numberOfTimes" : 6 ...

Error: The policy for the bucket could not be found. Error code: "NoSuchBucketPolicy"

We've encountered an issue while trying to attach a session policy in AWS, and we're puzzled by the error message that keeps popping up. Our setup involves utilizing S3 buckets and the Secure Token service. Even though we are able to obtain tem ...

The second nginx website is not functioning properly

I am facing a strange issue where the first reverse-proxy site is working perfectly fine, but when I try to add a second site-enabled with almost identical settings except for a few major changes like the server_name, nginx simply refuses to start or reloa ...

Out of the blue, my session stopped functioning

I am encountering a major issue with sessions. I am working on developing an application using "Redis" in node.js along with various libraries such as express. However, I have run into a problem where the sessions are no longer functioning properly. Desp ...

Guide on allowing a parent module to import a sub-module within another module in NodeJS

Module X │ └─ Module Y (devDependency in Module X's package.json) │ └─ Module Z (dependency in Module Y's package.json) Module Y is the focus of my current development efforts. However, I am aware that module Z will be called w ...

Can SKIP_FLIGHT_CHECK=true and openssl-legacy-provider be safely utilized in a React script when running npm start?

I've been working on a React app that contains outdated versions of the libraries listed in the package.json file. For example: "react": "^16.3.1", "react-scripts": "^3.0.1" ... While trying to install package ...

Detecting file changes in ExpressJS after writing data to a file.This

I'm facing an issue with my endpoints. One endpoint is responsible for writing JSON data to a static file, while another endpoint is supposed to retrieve and send that data. The problem arises when I make changes to the file but the endpoint still sen ...