cloudpanel-io / cloudpanel-ce

1.27k stars 106 forks source link

Missing www/non-www domain #472

Closed dcswalle closed 5 months ago

dcswalle commented 5 months ago

CloudPanel version(s) affected

2.4.2

Description

In old versions of CloudPanel if you add a new domain (eg: website.tld), in NginX www.website.tld is automatically added. For latest version I found that this is not working anymore. Old way of working for nginx domain default configuration:

server {
  listen 80;
  listen [::]:80;
  listen 443 ssl http2;
  listen [::]:443 ssl http2;
  {{ssl_certificate_key}}
  {{ssl_certificate}}
  server_name www.domainname.tld;
  return 301 https://domainname.tld$request_uri/;
}

server {
  listen 80;
  listen [::]:80;
  listen 443 ssl http2;
  listen [::]:443 ssl http2;
  {{ssl_certificate_key}}
  {{ssl_certificate}}
  server_name domainname.tld www1.domainname.tld;

2.4.2 nginx domain default configuration

server {
  listen 80;
  listen [::]:80;
  listen 443 quic;
  listen 443 ssl;
  listen [::]:443 quic;
  listen [::]:443 ssl;
  http2 on;
  http3 off;
  {{ssl_certificate_key}}
  {{ssl_certificate}}
  server_name domainname.tld;

How to reproduce

Create a new website and check vHosts.

Possible Solution

No response

Additional Context

No response

cloudpanel-io commented 5 months ago

How to reproduce it?

It works fine for me with a blank Ubuntu 24.04 and Debian 12 installation.

When I enter "www.domain.com", the redirects are generated properly.

server {
  listen 80;
  listen [::]:80;
  listen 443 quic;
  listen 443 ssl;
  listen [::]:443 quic;
  listen [::]:443 ssl;
  http2 on;
  http3 off;
  {{ssl_certificate_key}}
  {{ssl_certificate}}
  server_name domain.com;
  return 301 https://www.domain.com$request_uri;
}

server {
  listen 80;
  listen [::]:80;
  listen 443 quic;
  listen 443 ssl;
  listen [::]:443 quic;
  listen [::]:443 ssl;
  http2 on;
  http3 off;
  {{ssl_certificate_key}}
  {{ssl_certificate}}
  server_name www.domain.com www1.domain.com;
  {{root}}

....