We are happy to announce that Vesta is back under active development as of 25 February 2024. We are working on v1 candidate and expect to engage more with the community over the coming months. We are committed to open source, and we encourage contributors to help us build the future of Vesta.
Variables in nginx templates
Variables in nginx templates
Hi, first post!
I first want to say that I really like Vesta, it is simple but powerful, and the web gui is clean and easy to understand, and a lot of things "just work". Great job with it!
I am running Vesta on a server with a couple of websites, so far nothing too exotic. But I also have a mail server on another server that I want to forward mail.domain.com to using nginx on the Vesta machine as a proxy. I managed to create a template that worked and did just this, but here I encountered the first problem, it seems that changing a template and then switching templates of a domain crashes nginx some of the time.
This seems to be because the nginx.conf is not correctly cleaned up after the old template is removed and the new one is put in place. I tried to look at the code that does this and I gathered that it somehow finds the first and last line of the config block and removes it and then adds the new part. This somehow fails when the template is changed, but just maybe 50% of the time. The easy workaround I found for this was to manually clean up nginx.conf whenever this occured.
My second problem, which is not really a problem but a feature that I miss and would like to have. When I create a template called reverse-proxy for example, I have to hardcode the IP of the mail server into the template. This is not a problem when you have just one or two servers that nginx works as a proxy for, but when you have more of them a more elegant solution would be to have the template use a variable set in the web interface.
My proposition for this feature is that I enter for example %other-server-ip% in the template, Vesta should pick this up and offer me a field to enter this "template specific variable" in the nginx settings for the domain. I do not know if this is a feature anyone else needs, but I think it would open many interesting possibilities and make Vesta even better. Do you have any thoughts or suggestions?
Best regards Jon
I first want to say that I really like Vesta, it is simple but powerful, and the web gui is clean and easy to understand, and a lot of things "just work". Great job with it!
I am running Vesta on a server with a couple of websites, so far nothing too exotic. But I also have a mail server on another server that I want to forward mail.domain.com to using nginx on the Vesta machine as a proxy. I managed to create a template that worked and did just this, but here I encountered the first problem, it seems that changing a template and then switching templates of a domain crashes nginx some of the time.
This seems to be because the nginx.conf is not correctly cleaned up after the old template is removed and the new one is put in place. I tried to look at the code that does this and I gathered that it somehow finds the first and last line of the config block and removes it and then adds the new part. This somehow fails when the template is changed, but just maybe 50% of the time. The easy workaround I found for this was to manually clean up nginx.conf whenever this occured.
My second problem, which is not really a problem but a feature that I miss and would like to have. When I create a template called reverse-proxy for example, I have to hardcode the IP of the mail server into the template. This is not a problem when you have just one or two servers that nginx works as a proxy for, but when you have more of them a more elegant solution would be to have the template use a variable set in the web interface.
My proposition for this feature is that I enter for example %other-server-ip% in the template, Vesta should pick this up and offer me a field to enter this "template specific variable" in the nginx settings for the domain. I do not know if this is a feature anyone else needs, but I think it would open many interesting possibilities and make Vesta even better. Do you have any thoughts or suggestions?
Best regards Jon
Re: Variables in nginx templates
I agree with this 100%. I was actually forking VestaCp code to add a nginx confugurations UI, but I don't have time for it.
I also didn't know about usage of templates until today when I found force-ssl template.
Here is my use case, a proxy via nginx for:
1. Docker applications
2. NodeJs applications
3. Any other custom application like for exmaple GIT
I need mainly %port% variable since I could hardcode the localhost
So the simplest version of UI your proposed solution could work is to add client side ajax calls to vesta API, and show a (js based) popup window asking for those variables.
%other-server-ip% could be easly parsed to a lablel "Other Server IP" assuming removal of symbols "%" replacement "-" with space and applying proper/title case. This is easy.
Using this formatting, variables then could be case not sensitive so %otHer-serveR-ip% would generate same beautiful label.
Those variables to be html id like <input type="text" name="other-server-ip"> and when posted via ajax to be stored in session and replaced on save click.
This I could spent time to implement, but it would require devs to merge back the changes, I see many people doing many great things but they are never merged, the only thing you could do is download my code (if I would ever write it) and replace corresponding modified files, the problem then is updates, if you would update VestaCP you would lost variables UI
I would love if core devs of VestaCp would implement template variables.
The only thing at question is if %variable% syntax format is not reserved for Vesta, when we may need other format for user variables like @variable@ or #variable# etc.
I also didn't know about usage of templates until today when I found force-ssl template.
Here is my use case, a proxy via nginx for:
1. Docker applications
2. NodeJs applications
3. Any other custom application like for exmaple GIT
I need mainly %port% variable since I could hardcode the localhost
So the simplest version of UI your proposed solution could work is to add client side ajax calls to vesta API, and show a (js based) popup window asking for those variables.
%other-server-ip% could be easly parsed to a lablel "Other Server IP" assuming removal of symbols "%" replacement "-" with space and applying proper/title case. This is easy.
Using this formatting, variables then could be case not sensitive so %otHer-serveR-ip% would generate same beautiful label.
Those variables to be html id like <input type="text" name="other-server-ip"> and when posted via ajax to be stored in session and replaced on save click.
This I could spent time to implement, but it would require devs to merge back the changes, I see many people doing many great things but they are never merged, the only thing you could do is download my code (if I would ever write it) and replace corresponding modified files, the problem then is updates, if you would update VestaCP you would lost variables UI
I would love if core devs of VestaCp would implement template variables.
The only thing at question is if %variable% syntax format is not reserved for Vesta, when we may need other format for user variables like @variable@ or #variable# etc.
Re: Variables in nginx templates
Hi there,
I would really like to use this, any updates? I tried to edit the web php etc. but no luck.
Thanks in advance,
Remy
I would really like to use this, any updates? I tried to edit the web php etc. but no luck.
Thanks in advance,
Remy