# Error Code: 20 - I guess due to nginx template config

**URL:** <https://forum.hestiacp.com/t/error-code-20-i-guess-due-to-nginx-template-config/4368>\
**Category:** Uncategorized\
**Created:** [August 26, 2021, 2:41am UTC](https://forum.hestiacp.com/t/error-code-20-i-guess-due-to-nginx-template-config/4368 "2021-08-26T02:41:26Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![sebasira](https://forum.hestiacp.com/user_avatar/forum.hestiacp.com/sebasira/32/534_2.png) [@sebasira](https://forum.hestiacp.com/u/sebasira)\
**Post date:** [August 26, 2021, 2:41am UTC](https://forum.hestiacp.com/t/error-code-20-i-guess-due-to-nginx-template-config/4368/1 "2021-08-26T02:41:26Z")

</div>

Hi! I’m trying to update the nginx template for a given domain, and when changing the **Proxy Template** in the admin panel, I get:

> Error Code: 20

The template I’m editting is the exact copy of the **default.tpl** and **.stpl** with a few changes so I can handle different server names, differently

I perform 2 edits on those files. The second edit it what throws the Error Code 20.

First, let me introduce it. I have 2 domains: **[domain-one.com](http://domain-one.com)** and **[domain-two.com](http://domain-two.com)** on the same VPS. I have only one domain in the Hestia admin panel, which is **[domain-one.com](http://domain-one.com)**. And in the aliases section of it I add **[domain-two.com](http://domain-two.com)** so the SSL certificate would be valid for it as well.

The **default** NGINX config handles both in the same way. But I’d like to redirect domain-one to port 8888 and domain-two to port 9999. So I create a new template from the default one (name **my-template** ) and I have 2 server blocks, one with server\_name equal to [domain-one.com](http://domain-one.com) and the other with server\_name equal to [domain-two.com](http://domain-two.com)

Also the first one has proxy\_pass to port 8888 and the other to 9999.

In the admin I set that template to the site and everything works fine. Navigating to [domain-one.com](http://domain-one.com) gets me into the service running on port 8888 and navigating to [domain-two.com](http://domain-two.com), to the one on port 9999 as expected.

Now I’d like to modify the template to also allow a different hostname on domain-two. So:

[domain-one.com](http://domain-one.com) ----\> port 8888  
[domain-two.com](http://domain-two.com) ----\> port 9999  
[myhost.domain-two.com](http://myhost.domain-two.com) ----\> port 7777

So I added a new server bock to the template, with server\_name equal to [myhost.domain-two.com](http://myhost.domain-two.com) and proxy\_pass to port 7777.

Now I get to the admin panel again, change the **Proxy Template** to the **default** one, save it, and then back to **my-template** and I can not save it because I get the Error Code 20. And I don’t know what it means. If I delete the latest added server block of the template, the error is gone. So I guess there’s something wrong with my configuration in the template.

Thank you!

---

<div class="post-metadata">

**Author:** ![eris](https://forum.hestiacp.com/user_avatar/forum.hestiacp.com/eris/32/1241_2.png) [@eris](https://forum.hestiacp.com/u/eris)\
**Post date:** [August 26, 2021, 5:00am UTC](https://forum.hestiacp.com/t/error-code-20-i-guess-due-to-nginx-template-config/4368/2 "2021-08-26T05:00:12Z")

</div>

> **[GitHub - Myself5/hestiacp\_templates](https://github.com/Myself5/hestiacp_templates)**
>
> Contribute to Myself5/hestiacp\_templates development by creating an account on GitHub.

Proxy Extensions should be your port number.

---

<div class="post-metadata">

**Author:** ![sebasira](https://forum.hestiacp.com/user_avatar/forum.hestiacp.com/sebasira/32/534_2.png) [@sebasira](https://forum.hestiacp.com/u/sebasira)\
**Post date:** [August 26, 2021, 12:24pm UTC](https://forum.hestiacp.com/t/error-code-20-i-guess-due-to-nginx-template-config/4368/3 "2021-08-26T12:24:23Z")

</div>

@eris thank you for your response… I’m sorry I do not understand what you mean. I’ll paste the full **.tpl** template I have (the **.stpl** ) it’s very similar.

What I do not understand is how NGINX would know that I want to go to port 7777 if I replace it with **%proxy\_extensions%**

```nginx
# DOMAIN ONE
server {
    listen %ip%:%proxy_port%;
    server_name domain-one.com www.domain-one.com;

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

    location / {
        proxy_pass http://%ip%:8888;
        location ~* ^.+\.(%proxy_extensions%)$ {
            root %docroot%;
            access_log /var/log/%web_system%/domains/%domain%.log combined;
            access_log /var/log/%web_system%/domains/%domain%.bytes bytes;
            expires max;
            try_files $uri @fallback;
        }
    }

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

    location @fallback {
        proxy_pass http://%ip%:8888;
    }

    location ~ /\.ht {return 404;}
    location ~ /\.svn/ {return 404;}
    location ~ /\.git/ {return 404;}
    location ~ /\.hg/ {return 404;}
    location ~ /\.bzr/ {return 404;}

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

# DOMAIN TWO
server {
    listen %ip%:%proxy_port%;
    server_name domain-two.com www.domain-two.com;

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

    location / {
        proxy_pass http://%ip%:9999;
        location ~* ^.+\.(%proxy_extensions%)$ {
            root %docroot%;
            access_log /var/log/%web_system%/domains/%domain%.log combined;
            access_log /var/log/%web_system%/domains/%domain%.bytes bytes;
            expires max;
            try_files $uri @fallback;
        }
    }

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

    location @fallback {
        proxy_pass http://%ip%:9999;
    }

    location ~ /\.ht {return 404;}
    location ~ /\.svn/ {return 404;}
    location ~ /\.git/ {return 404;}
    location ~ /\.hg/ {return 404;}
    location ~ /\.bzr/ {return 404;}

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

# DOMAIN TWO - myhost
server {
    listen %ip%:%proxy_port%;
    server_name myhost.domain-two.com;

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

    location / {
        proxy_pass http://%ip%:7777;
        location ~* ^.+\.(%proxy_extensions%)$ {
            root %docroot%;
            access_log /var/log/%web_system%/domains/%domain%.log combined;
            access_log /var/log/%web_system%/domains/%domain%.bytes bytes;
            expires max;
            try_files $uri @fallback;
        }
    }

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

    location @fallback {
        proxy_pass http://%ip%:7777;
    }

    location ~ /\.ht {return 404;}
    location ~ /\.svn/ {return 404;}
    location ~ /\.git/ {return 404;}
    location ~ /\.hg/ {return 404;}
    location ~ /\.bzr/ {return 404;}

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

```

If I remove the last server block, everything works fine. But If I leave it I get an error code 20 as said before.

**Additional information** : as I can see in the repo you point me and other colleague recommend, I should replace:

```nginx
proxy_pass http://%ip%:8888;

```

with (use localhost on proxy pass)

```nginx
proxy_pass http://127.0.0.1:8888;

```

This is my first time dealing with NGINX, I’d appreciate if you can help me out here. Thank you very much!

---

<div class="post-metadata">

**Author:** ![sebasira](https://forum.hestiacp.com/user_avatar/forum.hestiacp.com/sebasira/32/534_2.png) [@sebasira](https://forum.hestiacp.com/u/sebasira)\
**Post date:** [August 29, 2021, 8:21pm UTC](https://forum.hestiacp.com/t/error-code-20-i-guess-due-to-nginx-template-config/4368/4 "2021-08-29T20:21:11Z")

</div>

I’m sorry to bother again… could anyone take a look at this, please? I can not make it work yet

---

<div class="post-metadata">

**Author:** ![eris](https://forum.hestiacp.com/user_avatar/forum.hestiacp.com/eris/32/1241_2.png) [@eris](https://forum.hestiacp.com/u/eris)\
**Post date:** [August 30, 2021, 6:45am UTC](https://forum.hestiacp.com/t/error-code-20-i-guess-due-to-nginx-template-config/4368/5 "2021-08-30T06:45:39Z")

</div>

1st create for each domain different templates files

Enable the templates and run nginx -t to test the templates it should show the errors you have

---

<div class="post-metadata">

**Author:** ![sebasira](https://forum.hestiacp.com/user_avatar/forum.hestiacp.com/sebasira/32/534_2.png) [@sebasira](https://forum.hestiacp.com/u/sebasira)\
**Post date:** [August 30, 2021, 12:09pm UTC](https://forum.hestiacp.com/t/error-code-20-i-guess-due-to-nginx-template-config/4368/6 "2021-08-30T12:09:14Z")

</div>

Thank you again @eris !

With the help of

```auto
nginx -t

```

I manage to find the error and solve it

> “proxy\_pass” cannot have URI part in location given by regular expression

Thank you very much!

---

<div class="post-metadata">

**Author:** ![Raphael](https://forum.hestiacp.com/user_avatar/forum.hestiacp.com/raphael/32/5217_2.png) [@Raphael](https://forum.hestiacp.com/u/Raphael)\
**Post date:** [August 30, 2021, 2:09pm UTC](https://forum.hestiacp.com/t/error-code-20-i-guess-due-to-nginx-template-config/4368/7 "2021-08-30T14:09:05Z")

</div>

Please share your both template files.

---

<div class="post-metadata">

**Author:** ![system](https://forum.hestiacp.com/uploads/default/original/1X/d9a5b68bf50ced83e880b56452e592b204761b19.png) [@system](https://forum.hestiacp.com/u/system)\
**Post date:** [September 29, 2021, 2:09pm UTC](https://forum.hestiacp.com/t/error-code-20-i-guess-due-to-nginx-template-config/4368/8 "2021-09-29T14:09:36Z")

</div>

Closed on September 29, 2021, 2:09pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
