Operating System & Version
centos
cPanel & WHM Version
90

kvvaradha

Member
Jul 9, 2014
6
0
51
cPanel Access Level
DataCenter Provider
I am trying to install node and react app inside cpanel. As i tried to manage and host the app and now, the app developer gave me nginx conf and unfortunately, he has no experience with apache and cpanel. But i want to run this inside our cpanel. As i tried with different stackoverflow and our forum questions. nothing helped to fix it. Here is the nginx conf
Code:
    upstream apiUpstream {

      # 1. Set your port here
      # If you didn't change it from .env, you can
      # ignore it and keep the default port 8080
      server 127.0.0.1:8080;
      keepalive 64;
    }

    server {
      listen 80;
      listen 443 ssl;

      # 2. Set your API domainname here
      server_name yourdomain.com;

      location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $http_host;

        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
                                       
        proxy_pass http://apiUpstream/;  
                                       
        proxy_redirect off;
        proxy_read_timeout 240s;
      }

      # 3. SSL certificate set below
      # Here is added a sample certificate format of letsencrypt
      # You are free to remove it and configure yours here
      ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem;
      ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem;
      include /etc/letsencrypt/options-ssl-nginx.conf;
      ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
    }
And i tried several links to get it working. Here are some.


and here is my stackoverflow question.


Nothing helped me.

Either i am facing CORS error or peerjs handshake failure error.

Error
Code:
Access to XMLHttpRequest at 'https://api.example.com/host/signIn' from origin 'https://example.com' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
and second error
Code:
 WebSocket connection to 'wss://api.tamilpos.com/peer/peerjs?key=peerjs&id=m3Kfglhpy3t&token=ekdxdw5hcpl' failed: Error during WebSocket handshake: 'Connection' header is missing
I am helpless in this situation.
 
Last edited by a moderator:

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
2,935
373
213
cPanel Access Level
Root Administrator
Hey there! Nginx is still in an experimental state on cPanel machines, but the best documentation for that would be here:


Have you already been able to review that and confirmed that Nginx is working by itself?

There are other users on the forum that have experience with Nginx and custom applications, so it's likely one of those users will comment as well.
 

kvvaradha

Member
Jul 9, 2014
6
0
51
cPanel Access Level
DataCenter Provider
Hello dude,

Thank you for the prompt response.

Actually i am feeling very comfortable with apache, i dont want to change it. I want to apply the similar configuration from nginx to apache. As i tried to apply the above told changes. But i cant make it work with that. Help me to convert the configuration from nginx to apache.
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
2,935
373
213
cPanel Access Level
Root Administrator
@kvvaradha - If you're going to be adjusting and customizing Apache on a cPanel system, you'll want to read the following documentation pages to make sure your work is compatible with the system:


Using the cPanel includes will ensure that your changes do not get overwritten by updates to Apache or cPanel configurations.

I also found this guide that explains how to setup Apache as a frontend for node.js:


so that might be helpful as well.

Can you look those over and see if that gets you pointed in the right direction?