Windows IIS with Next js App Internal Server Error 500 - node.js

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

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.

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

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

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

Angular application in IIS vs Node server

we have developed a Angular 4 application.
I have windows server 2012 R2 as production box
should i use node server to host the angular application, or IIS can also be used without any issue ?
i do not have any background experience so please suggest
I USUALLY USE IIS without any probs .. Node.js usually for developing purpose (with angular cli and webpack dev server) .. but then in production and in PrePRod (so on my servers) i usuall use IIS...
just check the webconfig file...
for example ..
1 - set default page as Index.html
2 - set rewrite rules for redirect on Index.html ..
..
and the be sure to have installed the URL REWRITE MODULE on IIS
Hope it helps you!

node js installation on Apache HTTP server (centOS)

I'm working at a project in school that includes Apache server.
All i need to do right now to start working with the server is create An index file (html, ph) at my folder on the server (inside the public_html) and the server will return that page.
but the thing is that I want to write the server with nodejs.
I have already manage to install node on the server but I know how to ignore the Apache server and start working with node.
I read about that and I saw that i need to start node on a different port? or use proxy?
but I really don't know that much about servers.
You can use apache as proxy for nodejs https://httpd.apache.org/docs/2.2/mod/mod_proxy.html.
ProxyPass / http://localhost:3000/
ProxyPassReverse / http://localhost:3000/
Or, if you want to run the nodejs not from root directory of server
ProxyPass /mynodejsproject http://localhost:3000/
ProxyPassReverse /mynodejsproject http://localhost:3000/
For example, nodejs application listens on 3000 port, apache on 80 port, and it proxies requests to nodejs application.
But i recommend you to use nginx as proxy for nodejs application, this is the config i used in my projects https://github.com/vodolaz095/hunt/blob/master/examples/serverConfigsExamples/nginx.conf
service apache2 stop Stops your apache server (It works on 80 port default)
Also there is a good tool for nodejs ,you will able to manage your nodeJS server(you can give 80 port now) like services with forever on nodeJS.(I assumed you know how to creating your nodejs http server)

Resources