How do I map the port number of a node.js app to a domain

Avatar
  • updated
  • Answered

How do I map the port number of a node.js app to a domain on my VPS? There are articles on Nginx but nothing really about the Apache way through panel on Inmotion?

Pinned replies
Avatar
anonymous
  • Answer
  • Answered

Hello! I checked with one of our senior Support Technicians and was told that you will need to enable a reverse proxy. I was also cautioned that usually it's best to just request our Support Team set this up for you, but here is an overview of the process if you want to set it up yourself. 

  1. Create two files, as well as manually create directories for your cPanel name and username: 
    /etc/apache2/conf.d/userdata/ssl/2/CPANEL_USERNAME/DOMAIN_NAME/proxy.conf
    /etc/apache2/conf.d/userdata/std/2/CPANEL_USERNAME/DOMAIN_NAME/proxy.conf
  2. Place the following in the one in userdata/std:
    ProxyPass "/" "http://127.0.0.1:5000/"
    ProxyPassReverse "/" "http://127.0.0.1:5000/"
  3. Place the following in the one in userdata/ssl:
    SSLProxyEngine on
    ProxyPass "/" "http://127.0.0.1:5000/"
    ProxyPassReverse "/" "http://127.0.0.1:5000/"
  4. When you set those up, 5000 should be the port that node is set up to and can be changed if you are using a different port
  5. Afterwards, run
    /scripts/rebuildhttpdconf 
    and then
    apachectl restart

I hope that helps! Remember, always make backups first, and definitely reach out to the Support Team if you aren't already comfortable with this sort of manual configuration. 

Avatar
anonymous
  • Answer
  • Answered

Hello! I checked with one of our senior Support Technicians and was told that you will need to enable a reverse proxy. I was also cautioned that usually it's best to just request our Support Team set this up for you, but here is an overview of the process if you want to set it up yourself. 

  1. Create two files, as well as manually create directories for your cPanel name and username: 
    /etc/apache2/conf.d/userdata/ssl/2/CPANEL_USERNAME/DOMAIN_NAME/proxy.conf
    /etc/apache2/conf.d/userdata/std/2/CPANEL_USERNAME/DOMAIN_NAME/proxy.conf
  2. Place the following in the one in userdata/std:
    ProxyPass "/" "http://127.0.0.1:5000/"
    ProxyPassReverse "/" "http://127.0.0.1:5000/"
  3. Place the following in the one in userdata/ssl:
    SSLProxyEngine on
    ProxyPass "/" "http://127.0.0.1:5000/"
    ProxyPassReverse "/" "http://127.0.0.1:5000/"
  4. When you set those up, 5000 should be the port that node is set up to and can be changed if you are using a different port
  5. Afterwards, run
    /scripts/rebuildhttpdconf 
    and then
    apachectl restart

I hope that helps! Remember, always make backups first, and definitely reach out to the Support Team if you aren't already comfortable with this sort of manual configuration.