Phusion Passenger + Apache + Node.js app runs on http but not https. 404 Error - node.js

I have a Phusion Passenger Node.js application configured with cPanel that ran perfectly on my primary domain. I created a new application that uses the same path but switched the domain to another domain on my account. On the old domain: ghv.xie.mybluehost.me, the application worked on both http and https.
http://ghv.xie.mybluehost.me/portal
https://ghv.xie.mybluehost.me/portal
On the new domain: csmithcpa.com, the app only works on http. https returns a 404 error.
http://csmithcpa.com/portal
https://csmithcpa.com/portal
I am not sure how to debug this or why it would return a 404 at all on https but completely work on http. Any help would be fantastic.
EDIT: I will keep adding useful information for debugging as more people ask questions about it.
cPanel/WHM access
Apache server
Phusion Passenger application manager
Node.js web application
-portal
--app.js
--node_modules
-public_html
--ghv.xie.mybluehost.me site files
--csmithcpa
---csmithcpa.com site files

Related

.Net Core not handling requests when defined in subdomain folder

I have a Linux Centos v7.9 with Apache installed. I published my web project to the server. For the backend I set it on port 90 and created a configuration file for apache with proxy server (to redirect to another port 31031, where .net 5 is listening and handling the requests. This works fine when I request my server ip with port 90. But when I wanted to set the backend as subdomain like api.domain.com and modified the configuration file, .net 5 is not handling the request anymore. When I request api.domain.com I see folder structure. What did I miss?
Here is the .conf file:
Service file:
Subdomain from cpanel:
Thanks.

Windows IIS with Next js App Internal Server Error 500

I'm trying to deploy my Next.js app on VPS Windows 10 with Plesk panel and Windows IIS.
The problem is I created domain name from Plesk panel and it works fine. And I have localhost for Next.js app on port 3000 I'm trying to connect to localhost:3000 with the domain using IIS rewrite Reverse Proxy
IIS rewrite Reverse Proxy:
But it gives me internal server error 500:
I tried this on React.js and Next.js, and Next.js with Express custom server. Still the same error.
But when I try with Vue.js or Node.js express server, it works just fine.
And when I open port like this domain.com:3000 it also works with react and next.
What can I do?
After searching for a while I found the solution problem is the iis can't use Url Rewrite proxy if you using gzip and Next.js provides gzip compression to compress rendered content and static files so to fix this error you need to turn gzip off or enable gzip on iis.
If you want to disable the gzip on next js follow this
https://nextjs.org/docs/api-reference/next.config.js/compression
If you want to using gzip enable gzip on iis this wll help you to using gzip
https://techcommunity.microsoft.com/t5/iis-support-blog/iis-acting-as-reverse-proxy-where-the-problems-start/ba-p/846259
Here I found the solution:
https://learn.microsoft.com/en-us/archive/blogs/friis/iis-with-url-rewrite-as-a-reverse-proxy-part-2-dealing-with-500-52-status-codes

Namecheap: Node JS Express App - App Route return 404 not found

Trying to get Simple Express Application up using NameCheap Shared Hosting.
I have set up my Node JS application as Described here NodeJS NameCheap Docs
Current Setup:
Application Root: url.com
Application URL: url.com
Application Startup File: server.js
I have ran NPM Install using the button provided
I have tried loading the URL http://url.com/hello Expecting Hello World to displayed in the Page.
var express = require("express");
var app = express();
const port = 3001;
app.set("port", port);
app.get("/hello", function(req, res) {
res.send("hello world");
});
app.listen(app.get("port"), () =>
console.log("Started listening on %s", app.get("port"))
);
The results I am getting when navigating to http://url.com/hello:
Not Found
The requested URL /index.php was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Namecheap only tells you how to configure the nodejs app however their hosting is based on cPanel which requires you configure the webserver (apache generally). Once you get an application running there’s a special button to register it for the apache configuration aka let it run from your domain. I don’t know the steps by heart but you should ask NC support to direct you to their documentation for configuring apache to run a nodejs app you configured.
If they do not link an article from their knowledge base use this link: https://confluence1.cpanel.net/plugins/servlet/mobile?contentId=17190639#content/view/17190639
Basically what you need now is to configure cPanel or ssh into your server and test your app locally. There’s a number of things that could cause your issues like incorrect apache configuration (your default port 80 is looking for php app), port not open/firewalled, application not registered - and all of this is cPanel specific.
To make sure you are reading the correct document check in namecheap cpanel for the docs button and review all the above. It should be obvious what needs configured - your nodejs code is probably not the cause here
In my case, it was the problem with .htaccess file. Adding the following rules in my .htaccess file present in the website's public directory helped me:
# CLOUDLINUX PASSENGER CONFIGURATION BEGIN
PassengerAppRoot "/home/<user>/<your_nodejs_app_folder>"
PassengerBaseURI "/."
PassengerNodejs "/home/<user>/nodevenv/<nodejs_app>/<version>/bin/node"
PassengerAppType node
PassengerStartupFile <startup_script>.js
# CLOUDLINUX PASSENGER CONFIGURATION END
Make the required changes in the above rules before pasting them in your .htaccess file. Also, just in case, make sure the port you are using is open, via customer support.

Reverse proxy using nginx on bluehost vps does not works with subdomains

I have bluehost VPS hosting on which I am hosting a node js app. I have configured my vps server and installed nginx on it. Now I am using the reverse proxy to redirect the domain.com to localhost:3000 which is running node js app. Now I have a second node js app that I want to run on sub.domain.com which is running on localhost:3001. I created the subdomain on bluehost then used the same reverse proxy config for sub.domain.com but it is not working.
and
?
I don't know why but adding
"proxy_redirect http://localhost:3001 http://sub.domain.com;"
in configuration file of subdomain fixed my problem :)
Solution Configuration

Cannot POST to express server from domain with SSL on it

I have an existing ssl certificate through LetsEncrypt for my domain. On the same server as my site I have an express app running at port :8080. Before adding the SSL to the domain I was able to make requests to http://domainname:8080.com. Now that the domain making the requests is https it obviously can't make those requests. If I instead make requests to https://domainname:8080.com, I get no response and instead get a timeout error.
I have attempted to curl -X -POST on the server manually and it returns (35) gnutls_handshake() failed: The TLS connection was non-properly terminated. If I however run the same command pointing to the non https domain it executes correctly. I also tried installing the https modules for express and pointing it to the same certs I'm using for the domain. For all my effort I cannot get this to work. What am I missing here? I want to make requests to a port on the same server that is serving my app.
Setup a reverse proxy in my nginx site config from the domain to the ip address the express server was running on. This solved all the issues I was having.

Resources