Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using template syntax in custom vhosts files #56

Open
rbackert opened this issue Jun 6, 2024 · 2 comments
Open

Using template syntax in custom vhosts files #56

rbackert opened this issue Jun 6, 2024 · 2 comments

Comments

@rbackert
Copy link

rbackert commented Jun 6, 2024

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.

@reynoldsalec
Copy link
Member

What version of the nginx plugin are you running @rbackert? Running lando version --all | grep '@lando/nginx' should show you.

I know we removed the render-template functionality and then re-added it in v1.0.0, so presumably a bug if you're running v1.1.0 (which I would anticipate is the case).

@rbackert
Copy link
Author

Yep, I'm running v1.1.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants