How to enable HTTPS for port access

#1
Hi there,

My server default vhost has been configured properly for https traffic so I can access web pages using https://myserver.com.

However when I serve a NodeJS app running at port 3000, I can only access the app via http for example http://myserver.com:3000.

How can I make it available at https://myserver.com:3000?

I have tried adding a listener with the "Port" field set to 3000 and "Secure" field set to Yes. Then I added the default vhost into the vhost mapping list. Then in the SSL tab of the listener I filled in the "Private Key File" and "Certificate File" fields with the same values coming from the default vhost because I presume the SSL cert should be the same.

Then after a graceful restart, https://myserver:3000 is still not showing the Node app.

Can anyone help?
 
#3
Hi @Cold-Egg

Yes I have followed the setup above using my existing OpenLiteSpeed-WordPress Digital Ocean droplet (prebuilt from the marketplace) and it's not working. I have tried it on both root domain and subdomain without any luck. Is it because this is a OLS-Wordpress droplet as opposed to the OLS-NodeJS droplet?

FYI, when I attempted the steps above I have stopped serving my NodeJS app (using pm2) and I have deleted the listener for port 3000 in the OLS admin.
 
#4
Talking about the OLS-NodeJS droplet, I went ahead and quickly spin up a new droplet using the DO marketplace prebuilt OLS-NodeJS droplet and followed the Getting Started guide. It works immediately with HTTPS.

Then I went into the OLS admin panel and tweaked the AppServer Context startup file value to point to my app JS file and it works. The whole app is now accessible at the root domain with HTTPS.

However there are some confusing instructions in the user guide here https://openlitespeed.org/kb/running-node-js-apps-with-openlitespeed/. For example:

1) When you look under the heading Verification, the guide tells us to access http://Server_IP: Port/node/ to view our app. However in the OLS-NodeJS droplet, the app is simply accessible without any explicit port in the URL even though the provided demo app is served at port 3000 (my custom app too). So the whole app is just available on the root domain level. Can you explain?

2) In the guide under the heading Set Up Context, it gives an example URI of /node/ for our AppServer Context and the app can then be accessed at http://Server_IP: Port/node/. When I tried tweaking the URI value on the OLS_NodeJS droplet from / to /api/, I expect the app to be accessible at https://myserver.com/api/get_users from the initial https://myserver.com/get_users. However this does not happen. The app simply stops working. Do you know why?

Looking forward to your response.
 

Cold-Egg

Administrator
#5
Hi @shaiful ,

The OpenLiteSpeed WordPress Image should also support all apps, you just need to config for apps.
Correct, litespeed/openlitespeed will receive and send data instead, and the app port will be ignored.
When you change context from `/` to `/api/`, does default demo script works?

Best,
Eric
 
#6
Hi @Cold-Egg

> When you change context from `/` to `/api/`, does default demo script works?
That is working indeed

I think it might be due to my mock API script running on JSON-Server and has routing custom configurations in it. Let me see if I can deploy it in a subdomain.
 
Top