Vesta Control Panel - Forum

Community Forum

Skip to content

Advanced search
  • Quick links
    • Main site
    • Github repo
    • Google Search
  • FAQ
  • Login
  • Register
  • Board index Main Section Web Server
  • Search

Variables in nginx templates

Questions regarding the Web Server
Apache + Nginx, Nginx + PHP5-FPM
Post Reply
  • Print view
Advanced search
3 posts • Page 1 of 1
jotab
Posts: 2
Joined: Mon Jan 23, 2017 12:29 am

Variables in nginx templates
  • Quote

Post by jotab » Mon Jan 23, 2017 12:41 am

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
Top

pawelcnet
Posts: 11
Joined: Fri Jul 15, 2016 8:16 pm
Contact:
Contact pawelcnet
Website

Os: Ubuntu 15x
Web: apache + nginx
Re: Variables in nginx templates
  • Quote

Post by pawelcnet » Wed Mar 22, 2017 6:14 pm

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.
Top

Remy
Posts: 1
Joined: Sun Jan 05, 2020 10:57 am

Os: Ubuntu 17x
Web: apache + nginx
Re: Variables in nginx templates
  • Quote

Post by Remy » Sun Jan 05, 2020 11:01 am

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
Top


Post Reply
  • Print view

3 posts • Page 1 of 1

Return to “Web Server”



  • Board index
  • All times are UTC
  • Delete all board cookies
  • The team
Powered by phpBB® Forum Software © phpBB Limited
*Original Author: Brad Veryard
*Updated to 3.2 by MannixMD
 

 

Login  •  Register

I forgot my password