Configuration Extensibility: Importing .TPL Files


  • | 790 points

    It would be really cool if you could import other manifest.tpl files inside a manifest.tpl file.

    Importing should just copy over the content of the imported file and inject it into that position then.

    This would be really useful for several uses, such as:

    1. in the nginx.sites-enabled.00-default.manifest.tpl file (and the SSL one), being able to add/import your own server{}'s easily that are defined in manifest.tpl as well (so they can use <<LARAGON_ROOT>> etc)

    2. being able to place all repeatedly-used lines (like for example the ssl lines in nginx sites enabled) into one file, to prevent it from being copy pasted everywhere

    For example:

    usr/tpl/nginx.sites-enabled.00-default.SSL.manifest.tpl:

    server {
        listen <<PORT>> default_server;
        listen <<SSL_PORT>> ssl default_server;
        server_name localhost;
        root "<<DOC_ROOT>>";
        
        index index.html index.htm index.php;
        
        location /. {
            deny all;
        }
        
        include "<<LARAGON_ROOT>>/etc/nginx/alias/*.conf";
        
        location / {
            try_files $uri $uri/ =404;
            autoindex on;
        }
        
        location ~ \.php$ {
            include snippets/fastcgi-php.conf;
            fastcgi_pass php_upstream;        
            #fastcgi_pass unix:/run/php/php7.0-fpm.sock;
        }
        
        # Enable SSL
        <<IMPORT "nginx.sites-enabled.ssl.manifest.tpl">>
        
        
        charset utf-8;
        
        location = /favicon.ico { access_log off; log_not_found off; }
        location = /robots.txt  { access_log off; log_not_found off; }
    }
    
    <<IMPORT "nginx.sites-enabled.01-somesite.manifest.tpl">>
    

    usr/tpl/nginx.sites-enabled.01-somesite.manifest.tpl:

    server {
        listen 8000 default_server;
        server_name localhost;
        root "<<DOC_ROOT>>/Symfony/LowEntryDataMain/public";
        
        index index.html index.htm index.php;
        
        location /. {
            deny all;
        }
        
        location / {
            try_files $uri /index.php$is_args$args;
        }
        
        location ~ ^/index\.php(/|$) {
            include snippets/fastcgi-php.conf;
            fastcgi_pass php_upstream;        
            #fastcgi_pass unix:/run/php/php7.0-fpm.sock;
            fastcgi_split_path_info ^(.+\.php)(/.*)$;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
            fastcgi_param DOCUMENT_ROOT $realpath_root;
            internal;
        }
        
        location ~ \.php$ {
            return 404;
        }
        
        # Enable SSL
        <<IMPORT "nginx.sites-enabled.ssl.manifest.tpl">>
        
        
        charset utf-8;
        
        location = /favicon.ico { access_log off; log_not_found off; }
        location = /robots.txt  { access_log off; log_not_found off; }
    }
    

    usr/tpl/nginx.sites-enabled.ssl.manifest.tpl:

    ssl_certificate "<<LARAGON_ROOT>>/etc/ssl/laragon.crt";
    ssl_certificate_key "<<LARAGON_ROOT>>/etc/ssl/laragon.key";
    ssl_session_timeout 5m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP;
    ssl_prefer_server_ciphers on;
    

    I think being able to do this really opens up the extensibility and the usability of laragon as it will allow a far cleaner and more effective way of handling the configuration.


Log in to reply
 

Looks like your connection to Laragon was lost, please wait while we try to reconnect.