Reputation: 8589
this is my first time working with Nginx, I am trying to create a sub-domain, but once I enter the sub-domain in the browser, I get the error This web page is not available :(
, so I am here for you to help me, please
I have one configuration for mobile which is
server {
large_client_header_buffers 1 1K;
listen 80;
server_name www.the-thing.mobi the-thing.mobi;
root /home/c0pt/things/thingsMobile/www;
location / {
index index.html index.htm
...
}
}
and the other for web, which is the one not working
server {
listen 80;
server_name www.desktop.the-thing.mobi desktop.the-thing.mobi;
root /home/c0pt/things/thingsWebApp/dist;
location / {
index index.html index.htm
...
}
}
if I enter www.the-thing.mobi
which is the sub-domain for mobile, everything works, but if I enter www.desktop.the-thing.mobi
, then the error message This web page is not available :(
comes up.
So, what am I doing wrong ?
Upvotes: 1
Views: 63
Reputation: 529
Try the config bellow
server {
large_client_header_buffers 1 1K;
listen 80;
server_name "~^(?<subdomain>[^.]*)\.?the-thing.mobi$" the-thing.mobi www.the-thing.mobi;
location / {
if($subdomain){
root /home/c0pt/things/thingsWebApp/dist;
}
if ($host = 'the-thing.mobi'|$host = 'www.the-thing.mobi') {
root /home/c0pt/things/thingsMobile/www;
}
index index.html index.htm
...
}
}
Upvotes: 1