Skip to content

Using template syntax in custom vhosts files #56

Description

@rbackert

If using Handlebars in a custom vhosts config is supposed to work, consider this issue a bug. If it's not, consider this issue a feature request.


Some of my custom vhosts configs use Handlebars syntax, as supported by https://github.com/bitnami/render-template and seen in https://github.com/lando/nginx/blob/main/config/nginx.conf.tpl. These configs worked before upgrading to lando 3.21, but not afterwards. It looks like the sed is processing the vhosts config instead of render-template, even though render-template is available. Relevant lines from container logs:

2024-06-06 11:43:54 landonginx 15:43:54.78 INFO  ==> copying /tmp/server.conf.lando to /opt/bitnami/nginx/conf/nginx.conf
2024-06-06 11:43:54 landonginx 15:43:54.78 INFO  ==> copying /tmp/fastcgi_params.lando to /opt/bitnami/nginx/conf/fastcgi_params
2024-06-06 11:43:54 landonginx 15:43:54.79 INFO  ==> Using sed to place correct webroot in vhost template
2024-06-06 11:43:54 landonginx 15:43:54.79 INFO  ==> Rendered template /tmp/vhosts.lando to /opt/bitnami/nginx/conf/vhosts/lando.conf
2024-06-06 11:43:54 landonginx 15:43:54.80 DEBUG ==> # WordPress single site rules. # Designed to be included in any server {} block. # LANDOWORDPRESSNGINXCONF # Upstream to abstract backend connection(s) for php upstream php { server fpm:9000; } server { listen 80 default_server; listen 443 ssl; server_name localhost; ssl_certificate /certs/cert.crt; ssl_certificate_key /certs/cert.key; ssl_verify_client off; ssl_session_cache shared:SSL:1m; ssl_session_timeout 5m; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; port_in_redirect off; client_max_body_size 100M; ## Your only path reference. root "/app/."; ## This should be in your http block and if it is, it's not needed here. index index.php; {{#if MEDIA_REDIRECT}} # Media redirect location ^~ /wp-content/uploads { expires max; log_not_found off; try_files $uri @prod_site; } location @prod_site { rewrite ^/(.*)$ "https://{{MEDIA_REDIRECT}}/$1" redirect; } {{/if}} location = /favicon.ico { log_not_found off; access_log off; } location = /robots.txt { allow all; log_not_found off; access_log off; } location / { # This is cool because no php is touched for static content. # include the "?$args" part so non-default permalinks doesn't break when using query string try_files $uri $uri/ /index.php?$args; } location ~ \.php$ { #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_script_name; include fastcgi_params; fastcgi_intercept_errors on; fastcgi_pass php; fastcgi_buffers 16 16k; fastcgi_buffer_size 32k; } location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ { expires max; log_not_found off; } }

All is well if start the app without custom config, run render-template "/path/to/custom-vhosts.conf.tpl" > /opt/bitnami/nginx/conf/vhosts/lando.conf inside the container, and restart nginx.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions