eggybot21

Member
Jan 25, 2020
15
3
3
Manila
cPanel Access Level
Root Administrator
Hi Guys,

I would like to know if it's possible to have a subdomain with custom port for example

apitrack.domain.com:6002

currently in cPanel if I created the subdomain apitrack.domain.com I want to add custom port 6002 so it can only be access with a specific port.

Can I know if you already encounter and solve this kind of setup?

TIA
 

HostNoc

Well-Known Member
Feb 20, 2020
155
38
28
Ontario
cPanel Access Level
Root Administrator
HI
1. First you have to open custom port in your server firewall
2. Install Mod Proxy In Easy Apache 4
3. Modify Apache configuration.This can easily be done inside of Web Host Manager -> Apache Configuration -> Include Editor:
From here, you’re going to want to modify the Pre VirtualHost Include file with the following:it should look like as below

<VirtualHost *:80>
ServerName sub.mydomain.com

ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>

ProxyPass / http://mydomain.com:6000/ (change port and domain anme according to your need)
ProxyPassReverse / http://mydomain.com:6000/
<Location />
Order allow,deny
Allow from all
</Location>
</VirtualHost>

After change and update run following command via SSH

/scripts/rebuildhttpdconf
service httpd restart

Regards
 
  • Like
Reactions: eggybot21

eggybot21

Member
Jan 25, 2020
15
3
3
Manila
cPanel Access Level
Root Administrator
I want add any available port for example 6002 or 6024, this will be attach for example to this sample subdomain
the purpose of this port will be use to handle payloads coming from the GT02A (GPS Tracker device), currently the problem that I have with the setup is that it needs a server with port and standard port 80 and 443 is not available in the option.

I'm not sure where to add the port, but I found some steps in the net for example on this link
but since this is a server settings and not totally sure about it and I might mess up the configuration.

Thanks,
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
13,382
2,106
363
cPanel Access Level
Root Administrator
cPanel avoids adjusting the firewall as much as possible, but we do have instructions on how to do that here. Just choose the firewall you're working with and these steps will help:



You can also install CSF if you want as that is free software and gives you the graphical option to manage the firewall inside WHM.
 
  • Like
Reactions: eggybot21

eggybot21

Member
Jan 25, 2020
15
3
3
Manila
cPanel Access Level
Root Administrator
Closing this post.

I found the answer from this one

which I totally forgot I can use the code "Listen [PORT]", Thanks again for the help support.
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
13,382
2,106
363
cPanel Access Level
Root Administrator
@eggybot21 - it's important to remember that you can't directly edit the Apache configuration on a cPanel server, as those updates will be overwritten as part of the nightly updates, or whenever there is an update to that specific package.

Please take a look at Advanced Apache Configuration | cPanel & WHM Documentation to see how you can create updates that will "stick"