Blesta SSL Error

Please Help.
my custom Template Working Fine on Blesta.

But when Try install ssl using my Template SSL not Installed.

Error - Error: Let's Encrypt validation status 400 (domain.net). Details: 403:"213.199.36.109: Invalid response from http://domain.net/.well-known/acme-challenge/HyLwM5JZLwc6KB2VwdY0OP-KhE03r32lTMSB-kaCV1E: 404"

My Blesta tpl -

server {
        listen  %ip%:%web_port%;
        server_name %domain_idn% %alias_idn%;
        root        %docroot%/blesta;
        index       index.php index.html index.htm;
        access_log  /var/log/nginx/domains/%domain%.log combined;
        access_log  /var/log/nginx/domains/%domain%.bytes bytes;
        error_log   /var/log/nginx/domains/%domain%.error.log error;

        # Include SSL forcing config (if applicable)
        include %home%/%user%/conf/web/%domain%/nginx.forcessl.conf*;

        # iFrame protection
        add_header X-Frame-Options SAMEORIGIN;

        location / {
                try_files $uri $uri/ /index.php?$query_string;
                rewrite ^(.*)/install.php$ /$1/install/redirect;
        }

        # PHP-FPM configuration for index.php
        location = /index.php {
                include /etc/nginx/fastcgi_params;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_pass %backend_lsnr%;
                include %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf*;
        }

        # Security: Block access to certain file types
        location ~ /\. {
                log_not_found off;
                return 404;
        }

        # Block access to specific file types
        location ~* \.(php|pdt|txt)$ {
                log_not_found off;
                return 404;
        }

        # Handle custom error pages
        location /error/ {
                alias %home%/%user%/web/%domain%/document_errors/;
        }

        # Handle vstats (web stats) access
        location /vstats/ {
                alias   %home%/%user%/web/%domain%/stats/;
                include %home%/%user%/web/%domain%/stats/auth.conf*;
        }

        # Include additional configurations
        include /etc/nginx/conf.d/phpmyadmin.inc*;
        include /etc/nginx/conf.d/phppgadmin.inc*;
        include %home%/%user%/conf/web/%domain%/nginx.conf_*;

}

blesta stpl -

server {
    listen      %ip%:%web_ssl_port% ssl;
    server_name %domain_idn% %alias_idn%;
    # Root location block (Update %docroot%/blesta to your own Directory / @blesta is Default)
    root        %sdocroot%/blesta;
    index       index.php index.html index.htm;
    access_log  /var/log/nginx/domains/%domain%.log combined;
    access_log  /var/log/nginx/domains/%domain%.bytes bytes;
    error_log   /var/log/nginx/domains/%domain%.error.log error;

        # SSL Configuration
        ssl_certificate     %ssl_pem%;
        ssl_certificate_key %ssl_key%;
        ssl_stapling        on;
        ssl_stapling_verify on;

        # ACME Challenge directory for SSL renewal
        location ^~ /.well-known/acme-challenge/ {
            root %sdocroot%;
            allow all;
        }

        # TLS 1.3 0-RTT anti-replay
        if ($anti_replay = 307) { return 307 https://$host$request_uri; }
        if ($anti_replay = 425) { return 425; }

        # Security: HSTS
        include %home%/%user%/conf/web/%domain%/nginx.hsts.conf*;

        # iFrame protection
        add_header X-Frame-Options SAMEORIGIN;

        # Main location block
        location / {
                try_files $uri $uri/ /index.php?$query_string;
                rewrite ^(.*)/install.php$ /$1/install/redirect;
        }

        # PHP-FPM configuration for index.php
        location = /index.php {
                include /etc/nginx/fastcgi_params;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_param HTTP_EARLY_DATA $rfc_early_data if_not_empty;
                fastcgi_pass %backend_lsnr%;
                include %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf*;
        }

        # Security: Block access to certain file types
        location ~ /\. {
                log_not_found off;
                return 404;
        }

        # Block access to specific file types (e.g., PHP scripts, PDT, TXT files)
        location ~* \.(php|pdt|txt)$ {
                log_not_found off;
                return 404;
        }

        # Error page location
        location /error/ {
                alias %home%/%user%/web/%domain%/document_errors/;
        }

        # vStats location
        location /vstats/ {
                alias   %home%/%user%/web/%domain%/stats/;
                include %home%/%user%/web/%domain%/stats/auth.conf*;
        }

        # Include additional configurations
        include /etc/nginx/conf.d/phpmyadmin.inc*;
        include /etc/nginx/conf.d/phppgadmin.inc*;
        include %home%/%user%/conf/web/%domain%/nginx.conf_*;

}

Please help me when i’ve used Custom Root location block - root %sdocroot%/blesta;

How to Fix SSL Install Error?

In blesta.stpl template modify this include:

        include %home%/%user%/conf/web/%domain%/nginx.conf_*;

to this:

        include %home%/%user%/conf/web/%domain%/nginx.ssl.conf_*;

Rebuild your web site and try again.

2 Likes

Also probally remove:

        # ACME Challenge directory for SSL renewal
        location ^~ /.well-known/acme-challenge/ {
            root %sdocroot%;
            allow all;
        }
3 Likes

Still now SSL not Installed… :frowning:
Also try using Others Domain.
When Select Blesta Template SSL not Installed, but SSL Installed Fine when Select Others Templates

Move this include:

        include %home%/%user%/conf/web/%domain%/nginx.conf_*;

below the first include:

# Include SSL forcing config (if applicable)
        include %home%/%user%/conf/web/%domain%/nginx.forcessl.conf*;

I’ve modifed both templates (I’ve tested them and it works using these templates):

blesta.tpl

server {
        listen  %ip%:%web_port%;
        server_name %domain_idn% %alias_idn%;
        root        %docroot%/blesta;
        index       index.php index.html index.htm;
        access_log  /var/log/nginx/domains/%domain%.log combined;
        access_log  /var/log/nginx/domains/%domain%.bytes bytes;
        error_log   /var/log/nginx/domains/%domain%.error.log error;

        # Include SSL forcing config (if applicable)
        include %home%/%user%/conf/web/%domain%/nginx.forcessl.conf*;
        include %home%/%user%/conf/web/%domain%/nginx.conf_*;
        
        # iFrame protection
        add_header X-Frame-Options SAMEORIGIN;

        location / {
                try_files $uri $uri/ /index.php?$query_string;
                rewrite ^(.*)/install.php$ /$1/install/redirect;
        }

        # PHP-FPM configuration for index.php
        location = /index.php {
                include /etc/nginx/fastcgi_params;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_pass %backend_lsnr%;
                include %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf*;
        }

        # Security: Block access to certain file types
        location ~ /\. {
                log_not_found off;
                return 404;
        }

        # Block access to specific file types
        location ~* \.(php|pdt|txt)$ {
                log_not_found off;
                return 404;
        }

        # Handle custom error pages
        location /error/ {
                alias %home%/%user%/web/%domain%/document_errors/;
        }

        # Handle vstats (web stats) access
        location /vstats/ {
                alias   %home%/%user%/web/%domain%/stats/;
                include %home%/%user%/web/%domain%/stats/auth.conf*;
        }

        # Include additional configurations
        include /etc/nginx/conf.d/phpmyadmin.inc*;
        include /etc/nginx/conf.d/phppgadmin.inc*;
}

blesta.stpl

server {
    listen      %ip%:%web_ssl_port% ssl;
    server_name %domain_idn% %alias_idn%;
    # Root location block (Update %docroot%/blesta to your own Directory / @blesta is Default)
    root        %sdocroot%/blesta;
    index       index.php index.html index.htm;
    access_log  /var/log/nginx/domains/%domain%.log combined;
    access_log  /var/log/nginx/domains/%domain%.bytes bytes;
    error_log   /var/log/nginx/domains/%domain%.error.log error;

        # SSL Configuration
        ssl_certificate     %ssl_pem%;
        ssl_certificate_key %ssl_key%;
        ssl_stapling        on;
        ssl_stapling_verify on;


        # TLS 1.3 0-RTT anti-replay
        if ($anti_replay = 307) { return 307 https://$host$request_uri; }
        if ($anti_replay = 425) { return 425; }

        # Security: HSTS
        include %home%/%user%/conf/web/%domain%/nginx.hsts.conf*;
        include %home%/%user%/conf/web/%domain%/nginx.ssl.conf_*;

        # iFrame protection
        add_header X-Frame-Options SAMEORIGIN;

        # Main location block
        location / {
                try_files $uri $uri/ /index.php?$query_string;
                rewrite ^(.*)/install.php$ /$1/install/redirect;
        }

        # PHP-FPM configuration for index.php
        location = /index.php {
                include /etc/nginx/fastcgi_params;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_param HTTP_EARLY_DATA $rfc_early_data if_not_empty;
                fastcgi_pass %backend_lsnr%;
                include %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf*;
        }

        # Security: Block access to certain file types
        location ~ /\. {
                log_not_found off;
                return 404;
        }

        # Block access to specific file types (e.g., PHP scripts, PDT, TXT files)
        location ~* \.(php|pdt|txt)$ {
                log_not_found off;
                return 404;
        }

        # Error page location
        location /error/ {
                alias %home%/%user%/web/%domain%/document_errors/;
        }

        # vStats location
        location /vstats/ {
                alias   %home%/%user%/web/%domain%/stats/;
                include %home%/%user%/web/%domain%/stats/auth.conf*;
        }

        # Include additional configurations
        include /etc/nginx/conf.d/phpmyadmin.inc*;
        include /etc/nginx/conf.d/phppgadmin.inc*;
}
2 Likes

Thanks @sahsanu
Its Now Working… :revolving_hearts:

2 Likes