Nginx Reverse Proxy question

Hi
I’m running my websites not as local files on the server but as containers, one container per website.
Now I need to define the Nginx Reverse Proxy for letting my VPS know how to point to the right container.
Domain1 → container1:8086, Domain2 ->container2:8087, etc…

In Ubuntu, it’s usually done with the main nginx.conf file for each domain.
But then we have to put this in /etc/nginx/sites-available and /etc/nginx/sites-enabled
But I don’t see anything like those two directories in the Nginx put in place by HestiaCP.
Is there another way to let Nginx load those specific conf files?

Each look like

server {
  listen 80;
  server_name domain1 ;

  location / {
    proxy_pass http:// localhost:8086;
  }
}

Thanks for any light on that matter.

Steve

You will need to create custom templates and assign them to the sites in question.

1 Like

Yes I found this page and skipped it as it says it’s mainly about cache, which I wasn’t interested in, so I eventually took the partial info about proxy from that page and digged into the templates directory.

I googled a lot around and barely found some info on how to use templates.

From some answers it seems that one has to create a cuctom nginx proxy template based on the orginal one in /usr/local/hestia/data/templates/web/nginx/proxy_ip.tpl

Then there is no clear explanation on how to write it.
Obviously we’re not supposed to copy the original template content into it, only whatever is specific to one’s needs. But knowing the original has no “include” to get the customizations into account, my guess is one has to clone it and customize it. Right?

And then it’s not clear where to put the file since the templates will be overwritten at each upgrade. Are the custom one (not default ones) safe in /usr/local/hestia/data/templates/web/nginx/ ?
Is the directory erased during the upgrade (then losing the custom templates) before fed back with the new templates?

If we have 15 domains to redirect, do we put the 15 custom templates there too?

Thanks for any clarifications.
Steve

That is how I interpret the directions that suggest copying them in the same directory. I am not using any custom templates to answer from personal experience.

You might. I suppose that depends on whether you are able to leverage variables to use one template to obtain different results.

OK thanks for the clarifications.
I’ll try this further tomorrow.
Just created a new template (proxy_prm.rpl) with basic info, I see it in the dropdown menu for my website, but when I save… “Error: proxy_prm proxy template doesn’t exist” whereas it’s offered to me.

1 Like

The extension must be tpl. Also, you should create two template versions:

1.- proxy_prm.tpl for the http version.
2.- proxy_prm.stpl for the https version.

2 Likes

yes.

yes.

if they all use different containers/apps/ports to proxy to, then: yes.

3 Likes

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