我正在尝试在 Ubuntu 上运行的 Nginx 上配置子子域。我已经有一个要访问的配置http://staging.mydomain.com
,它运行良好,但现在我需要访问这个 URL http://api.staging.mydomain.com
。
我尝试过这个,但没有成功:
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;
}
}
}
使用此配置我收到此错误:
The server at api.staging.mydomain.com can't be found, because the DNS lookup failed.
有什么想法吗?谢谢。
答案1
找不到 api.staging.example.com 的服务器,因为 DNS 查找失败。
您需要为此创建 DNSCNAME
或记录。A