以下のようにサブドメインの設定を行ったのですが、https://〇〇.comのトップページが表示されてしまいます。
おそらく、configの設定が原因だと思うのですが、どのようにすれば良いか解決策を教えていただけると、助かります。
また、サブドメイン用のconfファイルを作成したのですが、default.confにサブドメイン用のファイルを読み込むような記述は必要ないのでしょうか?
設定状況
Nginxのconfファイル
/etc/nginx/conf.d/
内にdefault.conf
と新たにサブドメイン名.conf
を作成。
サブドメイン名.conf
server { listen 80; server_name IPアドレス; keepalive_timeout 5; root /var/www/サブドメイン名/current/public; try_files $uri/index.html $uri.html $uri @app; location @app { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; proxy_pass http://127.0.0.1:3000; }
default.conf
server { listen 80; server_name 〇〇.com; return 301 https://〇〇.com$request_uri; } server { listen 443 ssl; server_name 〇〇.com; ssl_certificate /etc/letsencrypt/live/〇〇.com;/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/〇〇.com;/privkey.pem; charset UTF-8; location / { try_files $uri $uri/ /index.php?$query_string; root /var/www/html; index index.html index.html index.php; if ( -f $request_filename ) { expires 30d; break; } if (!-e $request_filename) { rewrite ^.+?(/.*.php)$ $1 last; rewrite ^ /index.php last; } } location ~ .php$ { root /var/www/html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }
nginx.conf
user nginx; worker_processes 1; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; keepalive_timeout 65; include /etc/nginx/conf.d/default.conf; include /etc/nginx/conf.d/サブドメイン名.conf; }
お名前.com DNSレコード設定
|ホスト名|TYPE|TTL|VALUE|状態|
|:--|:--:|:--:|:--:|
|〇〇.com|NS|86400|01.dnsv.jp|有効|
|〇〇.com|NS|86400|02.dnsv.jp|有効|
|〇〇.com|NS|86400|03.dnsv.jp|有効|
|〇〇.com|NS|86400|04.dnsv.jp|有効|
|〇〇.com|A|3600|IPアドレス|有効|
|サブドメイン名.〇〇.com|A|3600|IPアドレス|有効|
VPS(conohaを利用しています)
タイプ | 名称 | TTL | 値 |
---|---|---|---|
A(通常) | サブドメイン名 | 3600 | IPアドレス |
環境
conoha
CentOS7
Nginx
回答1件
あなたの回答
tips
プレビュー