Editing nginx site.conf file

I also ran into a similar issue and the problem was that the location needs to be put before the additional config files are loaded. Here’s what I ended up with:

server {
	server_name  _;
	return 302 $scheme://local.dev$request_uri;
}

server {
	server_name ~^(.*)\.local\.dev$ local.dev;
	root /app/public/;

	index index.php index.html index.htm;

	# Directives to send expires headers and turn off 404 error logging.
	location ~* \.(js|css|png|svg|jpe?g|gif|ico)$ {
		expires 24h;
		log_not_found off;
		try_files $uri $uri/ @production;
	}

	location @production {
		resolver 8.8.8.8;
		proxy_pass http://example.com/$uri;
	}

	include do-not-modify/*.conf;
}
2 Likes