Difficulty with proxy passing to subdomains

roni

New member
Joined
Jun 6, 2023
Messages
3
Background and Context
  • Version of directadmin: 1.650 (167f906b8837f25cee4da539830c8ecca7c650a2
  • We want to use Nginx in our server.
  • We have multiple application and subdomains, and we want to associate each subdomain to for each application.
  • Applications are webapps running on local server.
Problem
We create multiple subdomains and proxy pass them to a local running web application.
E.g. We have app.host.net and we want to configure it to pass all of the requests to localhost:8209.

We tried to add a server context and give proxy_pass to location /. We have noticed that whenever we customize the nginx.conf in [Server Manger > Custom HTTPD Configurations > (select nginx.conf for host.net) > Customize] it adds the customization to all of the subdomains.
We edited the nginx.conf locally after that, but whenever we add one more subdomain it automatically rewrites the nginx.conf.
 
if you create with subdomain management, you need if else condition to check which subdomain should be use with some application that you want.

if you want easy way, just create subdomain as new domain..
 
if you create with subdomain management, you need if else condition to check which subdomain should be use with some application that you want.
1. I'll try, but can you provide an example for nginx?
if you want easy way, just create subdomain as new domain..
2. Impossible, logically won't work, the only thing you would get in result is 403 error.
 
for nginx_apache

sub1.example.com:8209
sub2.... :8210

#CUSTOM1
Code:
|*if SUB="sub1"|

|?PROXY_IP="localhost"|
|?PORT_8080="8209"|
|?PORT_8081="8209"|

|*endif|

|*if SUB="sub2"|

|?PROXY_IP="localhost"|
|?PORT_8080="8210"|
|?PORT_8081="8210"|

|*endif|

or you can put normal nginx virtual host config between if else statement.
 
for nginx_apache

sub1.example.com:8209
sub2.... :8210

#CUSTOM1
Code:
|*if SUB="sub1"|

|?PROXY_IP="localhost"|
|?PORT_8080="8209"|
|?PORT_8081="8209"|

|*endif|

|*if SUB="sub2"|

|?PROXY_IP="localhost"|
|?PORT_8080="8210"|
|?PORT_8081="8210"|

|*endif|

or you can put normal nginx virtual host config between if else statement.

Thanks, I managed to resolve the problem with Nginx "if" statement and $host variable.
 
Back
Top