ワイルドカード サブドメインを使用するサーバーを持っています。ポート3000のリバースプロキシで実行されるnuxtjs、nginxを使用しています。すべてのユーザーは、サイトにサブドメインを作成できる必要があります。たとえば、subdomain.learnbot.tk
これはlearnbot.tk/school/{subdomain-name}
. すべてのユーザーは、自分の を指す cname を作成できる必要がありますsubdomain.learnbot.tk
。
しかし、ドメイン名を使用してホスト@
とターゲットを使用して CNAME レコードを作成すると、 404 が返されます。subdomain.learnbot.tk
https://creatorbrandedsite.tk/
ワイルドカード サブドメインの conf ファイルは次のとおりです。
server {
listen 80;
server_name *.learnbot.tk;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl http2 default_server;
listen [::]:443 ssl http2 default_server;
#include snippets/ssl-example.com.conf;
#include snippets/ssl-params.conf;
ssl_certificate /etc/letsencrypt/live/learnbot.tk/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/learnbot.tk/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
root /home/subdomain/learnbot.tk/public/current;
index index.php index.html index.htm index.nginx-debian.html;
server_name *.learnbot.tk;
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
location /blog {
try_files $uri $uri/ /index.php$is_args$args;
}
# For Lets Encrypt certbot
location ~ /.well-known {
allow all;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
location ~ /\.ht {
deny all;
}
location /favicon.ico { alias /var/www/html/example/favicon.ico; }
location = /favicon.ico { log_not_found off; access_log off; }
location = /robots.txt { log_not_found off; access_log off; allow all; }
}
メインドメインの nuxtjs conf ファイル
server {
index index.html;
server_name learnbot.tk www.learnbot.tk;
location / {
# WARNING: https in proxy_pass does NOT WORK!! I spent half a day debugging this.
#proxy_pass https://localhost:4001;
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
error_page 404 /custom_404.html;
location = /custom_404.html {
root /etc/nginx/sites-available/custom_nginx_error_pages;
internal;
}
listen [::]:443 ssl http2; # managed by Certbot, modified by Kunal to add http2
listen 443 ssl http2; # managed by Certbot, modified by Kunal to add http2
#Install SSL certificates and configure https:// on a per-domain-basis by running:
#sudo certbot --nginx
#(when prompted, be sure to select the option to set up redirects from http to https and effectively "disable" http)
ssl_certificate /etc/letsencrypt/live/learnbot.tk/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/learnbot.tk/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
server_name learnbot.tk;
if ($host = learnbot.tk) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
listen [::]:80;
return 404; # managed by Certbot
}