Welcome! Log In Create A New Profile

Advanced

Multiple domains with one subdomain in common

Posted by morten 
Multiple domains with one subdomain in common
June 11, 2009 04:39AM
Hey all,

In our reverse proxies we would like to send all requests for [i]*.domain1.com[/i], [i]*.domain2.com[/i] ... [i]*.domainN.com[/i] to one server and requests for [i]webmail.*[/i] to the mail front-end server (running SquirrelMail).

The primary domain1.conf file for the domains look like this
[code]
server {
listen 80;
server_name domain1.com *.domain1.com;
access_log /var/log/nginx/domain1/access.log;
location / {
proxy_pass http://webapp5;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect false;
}
}
[/code]

And here goes the generic [i]webmail.conf[/i] file for the webmail
[code]
server {
listen 80;
server_name webmail.* ;
access_log /var/log/nginx/webmail/access.log;
location / {
proxy_pass http://mail1;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect false;
}
}
[/code]

But the webmail part doesn't work no matter if the [i]webmail.conf[/i] file is loaded before or afterwards [i]domain1.conf[/i]. I tried to rename [i]webmail.conf[/i] to [i]0-webmail.conf[/i] but without the result.

Any ideas on how to do this? I would like to avoid having to setup the webmail pointer explicitly in every [i]domainX.conf[/i] file and also I don't want to edit the [i]webmail.conf[/i] file entering every domain in there with [i]webmail.[/i] prefixed.

Thanks for such a great forum for such a great server!

Regards
Re: Multiple domains with one subdomain in common
June 11, 2009 11:27AM
I wonder if the wildcard simply isn't being picked up in the [i]webmail.conf [/i] file.

Please print the output from

[code]
# /path/to/nginx -t
[/code]

--
Jim Ohlstein
Re: Multiple domains with one subdomain in common
June 11, 2009 11:31AM
Output from [i]nginx -t[/i]
[code]
2009/06/11 17:28:02 [info] 7240#0: the configuration file /etc/nginx/nginx.conf syntax is ok
2009/06/11 17:28:02 [info] 7240#0: the configuration file /etc/nginx/nginx.conf was tested successfully
[/code]
Re: Multiple domains with one subdomain in common
June 11, 2009 11:47AM
It was worth looking at. :)

If you include:

[code]
server {
listen 80;
server_name webmail.domain1.com ;
access_log /var/log/nginx/webmail/access.log;
location / {
proxy_pass http://mail1;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect false;
}
}
[/code]

in your domain1.conf file, which is what you want to avoid, does it work correctly? (It should.)

Your other option would be to explicitly define all of the subdomains in domain1.conf with the exception of "webmail". That might work. But it seems that it's matching the wildcard in "*.domain1.com" first no matter what you do.

--
Jim Ohlstein
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 108
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready