Gabriel03

Registered
Jul 14, 2021
4
0
1
Romania
cPanel Access Level
Root Administrator
Hello!

I'm trying to make a reverse proxy with Nginx for a subdomain.

This is the config file: 1626289392800.png

The domain from the server_name is changed for privacy reasons.

When I try to access the webpage it shows me this:
1626289489852.png

I've put the config file in /etc/nginx/conf.d. The file name is api.mydomain.com.conf
 
Last edited by a moderator:

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
6,923
912
313
cPanel Access Level
Root Administrator
Hey there! By default, cPanel will handle all of this for you if you are using our Nginx tools at NGINX with Reverse Proxy | cPanel & WHM Documentation. We create a configuration that proxies 80 to port 81 and 443 to 444, so this would cover all subdomains created with cPanel. Can you let me know what is custom about this subdomain that would require unique routing? We don't recommend trying to serve content out of the /var/www/ directory.
 

Gabriel03

Registered
Jul 14, 2021
4
0
1
Romania
cPanel Access Level
Root Administrator
Hey there! By default, cPanel will handle all of this for you if you are using our Nginx tools at NGINX with Reverse Proxy | cPanel & WHM Documentation. We create a configuration that proxies 80 to port 81 and 443 to 444, so this would cover all subdomains created with cPanel. Can you let me know what is custom about this subdomain that would require unique routing? We don't recommend trying to serve content out of the /var/www/ directory.
Hello! I'm trying to make a reverse proxy that redirects traffic to localhost:9999.

So when people access api.mydomain.com to serve content from the Node.JS server on my VPS at localhost:9999.
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
6,923
912
313
cPanel Access Level
Root Administrator
Thanks for the additional details. I believe you're trying to do something like this:


just with Nginx/Node.JS instead of Tomcat. Can you try that and see if that helps?
 

Gabriel03

Registered
Jul 14, 2021
4
0
1
Romania
cPanel Access Level
Root Administrator
Thanks for the additional details. I believe you're trying to do something like this:


just with Nginx/Node.JS instead of Tomcat. Can you try that and see if that helps?
I've done as you told me and it works. Thank you!

But there is still one problem: I only have a file named username.conf ( instead of "username" is the actually username that I set on WHM ).
How can I split it in different files for each domain?

So I would have like a folder named username with the domains and subdomains configuration in separate files.
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
6,923
912
313
cPanel Access Level
Root Administrator
i'm glad we're making some progress! In the example, they have a username directory:

/etc/apache2/conf.d/userdata/std/2_4/$username/$domain.tld/tomcatproxypass.conf:

so you could create additional configuration files under /etc/apache2/conf.d/userdata/std/2_4/$username/ to perform that work with each subdomain.
 
  • Like
Reactions: Gabriel03

Gabriel03

Registered
Jul 14, 2021
4
0
1
Romania
cPanel Access Level
Root Administrator
i'm glad we're making some progress! In the example, they have a username directory:

/etc/apache2/conf.d/userdata/std/2_4/$username/$domain.tld/tomcatproxypass.conf:

so you could create additional configuration files under /etc/apache2/conf.d/userdata/std/2_4/$username/ to perform that work with each subdomain.
Ok, thank you very much!