I'm trying configure a sub-subdomain on Nginx running on Ubuntu. I already have a configuration to access http://staging.mydomain.com
and it works fine but now I need to access this URL http://api.staging.mydomain.com
.
I tried this but without success:
upstream myapp {
server unix:/var/tmp/myapp.sock;
}
upstream myapp_api {
server unix:/var/tmp/myapp_api.sock;
}
# Configuration to subdomain
server {
listen 80 default_server;
server_name staging.mydomain.com;
location / {
root /var/www/myapp/current/public;
if (!-f $request_filename) {
proxy_pass http://myapp;
break;
}
}
}
# Configuration to sub-subdomain
server {
listen 80;
server_name api.staging.mydomain.com;
location / {
root /var/www/api_myapp/current/public;
if (!-f $request_filename) {
proxy_pass http://api_myapp;
break;
}
}
}
With this configuration I received this error:
The server at api.staging.mydomain.com can't be found, because the DNS lookup failed.
Any ideas? Thank you.