带有子域的 Nginx

Nginx with subdomain

我想知道如何在我的 debian 服务器上使用子域访问我的网站?

目前:

  • access by IP [ok]
  • access by subdomain "blog.mydomain.com" : I have this error "ERR_CONNECTION_REFUSED" [nok]

在我的 /etc/nginx/sites-enabled/default 我有 "server_name mydomain.com"

当我 ping 我的 blog.mydomain.com 子域时,我有正确的 IP。

/etc/nginx/sites-enabled/default

server {
    listen 80;
    listen [::]:80;

    root /var/www/html;

    index index.html index.htm index.nginx-debian.html;

    server_name mydomain.com;

    location / {
        try_files $uri $uri/ =404;
    }
}

我检查我的 conf :

root@debian:/var/www/html# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

我用这个更新了我的 conf :

server_name blog.mydomain.com;

我再次生成了 SSL (certbot),它起作用了!