Virtual hosts missing the "return 301" part to redirect www to non-www and vice versa #257

Closed
opened 2026-04-05 20:26:13 +02:00 by MrUnknownDE · 0 comments
Owner

Originally created by @nemseck on 3/12/2024

CloudPanel version(s) affected

2.4.1

Description

I've installed Cloudpanel on two different VM, both are using Ubuntu 22.04. One has a public IP resolution while the other is on my local machine just for testing purposes.

While the one on local environment is working exactly as expected, the one with public IP has a problem that comes out at every new virtual host creation.

This is the right standard configuration that comes out on the environment working properly

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

server {
  listen 80;
  listen [::]:80;
  listen 443 ssl http2;
  listen [::]:443 ssl http2;
  {{ssl_certificate_key}}
  {{ssl_certificate}}
  server_name www.mylocaltest.mr www1.mylocaltest.mr;
  {{root}}
  etc etc..
  

Instead this is the virtual host that comes out on the enviroment that is missing the bold part of the previous example

server {
  listen 80;
  listen [::]:80;
  listen 443 ssl http2;
  listen [::]:443 ssl http2;
  {{ssl_certificate_key}}
  {{ssl_certificate}}
  server_name www.mypublictest.it;
  {{root}}
  etc et ..
  

How to reproduce

I don't know how to reproduce this issue, I've analyzed all the files under /home/clp/ folders and also confronted all the etc/nginx/nginx.conf files of both environments.

I feel like there's something that is not including properly the rules stored in home/clp/htdocs/app/files/resources/nginx/vhost_template/redirect file (checked also this one, which is ok in both environments).

Possible Solution

I know that a solution would be manually adding the missing rules but I'd like to have the standard behaviour of Cloudpanel virtual hosts generation.

Additional Context

Please note that on the "bugged" environment, at the end of installation I had this alert:

dpkg: error processing package cloudpanel (--configure): installed cloudpanel package post-installation script subprocess returned error exit status 1
E: Sub-process /usr/bin/dpkg returned an error code (1)

Anyway after I solved this issue I successfully performed an "apt reinstall cloudpanel" to complete post-installation scripts.

*Originally created by @nemseck on 3/12/2024* ### CloudPanel version(s) affected 2.4.1 ### Description I've installed Cloudpanel on two different VM, both are using Ubuntu 22.04. One has a public IP resolution while the other is on my local machine just for testing purposes. While the one on local environment is working exactly as expected, the one with public IP has a problem that comes out at every new virtual host creation. This is the right standard configuration that comes out on the environment working properly <pre> **server { listen 80; listen [::]:80; listen 443 ssl http2; listen [::]:443 ssl http2; {{ssl_certificate_key}} {{ssl_certificate}} server_name mylocaltest.mr; return 301 https://www.mylocaltest.mr$request_uri; }** server { listen 80; listen [::]:80; listen 443 ssl http2; listen [::]:443 ssl http2; {{ssl_certificate_key}} {{ssl_certificate}} server_name www.mylocaltest.mr www1.mylocaltest.mr; {{root}} etc etc.. </pre> Instead this is the virtual host that comes out on the enviroment that is missing the bold part of the previous example <pre> server { listen 80; listen [::]:80; listen 443 ssl http2; listen [::]:443 ssl http2; {{ssl_certificate_key}} {{ssl_certificate}} server_name www.mypublictest.it; {{root}} etc et .. </pre> ### How to reproduce I don't know how to reproduce this issue, I've analyzed all the files under /home/clp/ folders and also confronted all the etc/nginx/nginx.conf files of both environments. I feel like there's something that is not including properly the rules stored in home/clp/htdocs/app/files/resources/nginx/vhost_template/redirect file (checked also this one, which is ok in both environments). ### Possible Solution I know that a solution would be manually adding the missing rules but I'd like to have the standard behaviour of Cloudpanel virtual hosts generation. ### Additional Context Please note that on the "bugged" environment, at the end of installation I had this alert: dpkg: error processing package cloudpanel (--configure): installed cloudpanel package post-installation script subprocess returned error exit status 1 E: Sub-process /usr/bin/dpkg returned an error code (1) Anyway after I solved this issue I successfully performed an "apt reinstall cloudpanel" to complete post-installation scripts.
Sign in to join this conversation.