Welcome! Log In Create A New Profile

Advanced

How can I work with several sub-domains in NGINX?

Posted by geekd 
How can I work with several sub-domains in NGINX?
April 16, 2015 08:36AM
I understand to a certain degree how the regex expressions work for nginx and server_name, but there's one regex that I just cannot get my head around.

I want to have several sub-domains in the form of:

app.example.com

a.app.example.com

b.app.example.com

My regex is: ~^(?<app>.+)\.example\.com$

My root directory points to: /path/to/nginx/html/example_app/$app

The logical values of $app should be 'app', 'a.app' and 'b.app'

However, the corresponding directories are not found.

I've tried having directories called: 'app','app.example' and 'app.example.com' for app.example.com

And 'a','a.app','a.app.example' and 'a.app.example.com' for a.app.example.com' and still errors.

Can anyone assist? Thanks in advance!
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 218
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