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

Error: Coping nginx.conf template to site directory #110

Closed
cjkoepke opened this Issue Aug 13, 2018 · 4 comments

Comments

Projects
None yet
2 participants
@cjkoepke

cjkoepke commented Aug 13, 2018

I need to increase the max file size upload for a site. I updated the php.ini file, but when trying to create a local site's custom nginx.conf configuration, I get this error (without any changes, and when copied from the template directory):

Could not get Nginx container internal IP. Skipping adding local site hosts to PHP containers.

This happens with no manipulation to the file, and all I'm wanting to add is:

client_max_body_size [X]M;

@cjkoepke

This comment has been minimized.

Show comment
Hide comment
@cjkoepke

cjkoepke Aug 13, 2018

@philipnewcomer More information:

2018/08/13 20:50:03 [emerg] 1#1: directive "server_name" is not terminated by ";" in /etc/nginx/conf.d/default.conf:137
nginx: [emerg] directive "server_name" is not terminated by ";" in /etc/nginx/conf.d/default.conf:137

This seems to be the problem as it terminates starting NGINX. Here's my nginx.conf file:

server {
    client_max_body_size 150M;

	listen 80;
	server_name {{server_name}};
	root /var/www/html/sites/{{site_name}}/htdocs;

	listen 443 ssl;
	ssl on;
	ssl_certificate /etc/nginx/https-certificate.cert;
	ssl_certificate_key /etc/nginx/https-certificate.key;

{{wp_uploads_proxy_config}}

	location / {
		index index.php index.html;
		try_files $uri $uri/ /index.php?$args;
	}

	location = /favicon.ico {
		access_log off;
		log_not_found off;
	}

	location = /robots.txt {
		try_files $uri $uri/ /index.php?$args;
		access_log off;
		log_not_found off;
	}

	location ~* \.(css|eot|gif|html|ico|jpe?g|js|mov|mp3|png|svg|ttf|txt|woff)$ {
		access_log off;
		expires 0;
	}

	# Rewrite requests to `/wp-.*` on subdirectory installs.
	if ( !-e $request_filename ) {
		rewrite /wp-admin$ $scheme://$host$uri/ permanent;
		rewrite ^/[_0-9a-zA-Z-]+(/wp-.*) $1 last;
		rewrite ^/[_0-9a-zA-Z-]+(/.*\.php)$ $1 last;
	}

	location ~ \.php$ {
		try_files $uri =404;
		include fastcgi_params;
		fastcgi_index index.php;
		fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
		fastcgi_pass {{php_backend}}-$xdebug_suffix;
		fastcgi_read_timeout 3600s;
	}
}

cjkoepke commented Aug 13, 2018

@philipnewcomer More information:

2018/08/13 20:50:03 [emerg] 1#1: directive "server_name" is not terminated by ";" in /etc/nginx/conf.d/default.conf:137
nginx: [emerg] directive "server_name" is not terminated by ";" in /etc/nginx/conf.d/default.conf:137

This seems to be the problem as it terminates starting NGINX. Here's my nginx.conf file:

server {
    client_max_body_size 150M;

	listen 80;
	server_name {{server_name}};
	root /var/www/html/sites/{{site_name}}/htdocs;

	listen 443 ssl;
	ssl on;
	ssl_certificate /etc/nginx/https-certificate.cert;
	ssl_certificate_key /etc/nginx/https-certificate.key;

{{wp_uploads_proxy_config}}

	location / {
		index index.php index.html;
		try_files $uri $uri/ /index.php?$args;
	}

	location = /favicon.ico {
		access_log off;
		log_not_found off;
	}

	location = /robots.txt {
		try_files $uri $uri/ /index.php?$args;
		access_log off;
		log_not_found off;
	}

	location ~* \.(css|eot|gif|html|ico|jpe?g|js|mov|mp3|png|svg|ttf|txt|woff)$ {
		access_log off;
		expires 0;
	}

	# Rewrite requests to `/wp-.*` on subdirectory installs.
	if ( !-e $request_filename ) {
		rewrite /wp-admin$ $scheme://$host$uri/ permanent;
		rewrite ^/[_0-9a-zA-Z-]+(/wp-.*) $1 last;
		rewrite ^/[_0-9a-zA-Z-]+(/.*\.php)$ $1 last;
	}

	location ~ \.php$ {
		try_files $uri =404;
		include fastcgi_params;
		fastcgi_index index.php;
		fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
		fastcgi_pass {{php_backend}}-$xdebug_suffix;
		fastcgi_read_timeout 3600s;
	}
}
@philipnewcomer

This comment has been minimized.

Show comment
Hide comment
@philipnewcomer

philipnewcomer Aug 14, 2018

Member

@cjkoepke I believe you're trying to create a custom Nginx configuration for a specific site (as opposed to modifying the global Nginx configuration), is that correct?

When you have a file named nginx.conf in a local site's directory, it is used as-is, meaning that the placeholders that are present in the template are not interpreted in the override file. So in your case, since {{server_name}} is replaced with the actual server name when it's present in the template, but it remains as {{server_name}} in your override file, the configuration is invalid, causing the Nginx error.

So when you want to override the Nginx configuration for a site, you need to copy the generated configuration for that site out of the ~/.pilothouse/_run/nginx-compiled-sites.conf file, which has the placeholders replaced with real values. (nginx-compiled-sites.conf will contain the generated configuration of all existing local sites, so make sure you copy only the configuration for the one site you want to override.) Then you can place that generated configuration into nginx.conf in your local site directory and then modify it to suit.

Member

philipnewcomer commented Aug 14, 2018

@cjkoepke I believe you're trying to create a custom Nginx configuration for a specific site (as opposed to modifying the global Nginx configuration), is that correct?

When you have a file named nginx.conf in a local site's directory, it is used as-is, meaning that the placeholders that are present in the template are not interpreted in the override file. So in your case, since {{server_name}} is replaced with the actual server name when it's present in the template, but it remains as {{server_name}} in your override file, the configuration is invalid, causing the Nginx error.

So when you want to override the Nginx configuration for a site, you need to copy the generated configuration for that site out of the ~/.pilothouse/_run/nginx-compiled-sites.conf file, which has the placeholders replaced with real values. (nginx-compiled-sites.conf will contain the generated configuration of all existing local sites, so make sure you copy only the configuration for the one site you want to override.) Then you can place that generated configuration into nginx.conf in your local site directory and then modify it to suit.

@cjkoepke

This comment has been minimized.

Show comment
Hide comment
@cjkoepke

cjkoepke Aug 15, 2018

@philipnewcomer Thank you, I didn't realize it wasn't dynamic.

cjkoepke commented Aug 15, 2018

@philipnewcomer Thank you, I didn't realize it wasn't dynamic.

@philipnewcomer

This comment has been minimized.

Show comment
Hide comment
@philipnewcomer

philipnewcomer Aug 15, 2018

Member

I can see how it might be useful to be able to use placeholders in the configuration override file, and how it's unintuitive that they can't currently be used there. So I've created an issue (#111) to add this feature.

Member

philipnewcomer commented Aug 15, 2018

I can see how it might be useful to be able to use placeholders in the configuration override file, and how it's unintuitive that they can't currently be used there. So I've created an issue (#111) to add this feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment