nginx - 带子域的Nginx
我想知道如何才能在我的debian服务器上用子域名访问我的网站?
目前:
- 通过IP访问 [ok]
- 通过子域 "blog.mydomain.com "访问:我有这个错误 "ERR_CONNECTION_REFUSED" [nok] 。
在我的etcnginxsites-enableddefault中,我有 "server_name mydomain.com"
当我ping我的blog.mydomain.com子域名时,我有正确的IP。
etcnginxsites-enableddefault
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。
[email protected]:/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),然后它就工作了!