<commit_before>##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# http://wiki.nginx.org/Pitfalls
# http://wiki.nginx.org/QuickStart
# http://wiki.nginx.org/Configuration
#
# Generally, you will want to move this file somewhere, and start with a clean
# file but keep this around for reference. Or just disable in sites-enabled.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##

<% if not @vhost[:ssl].to_s.empty? %>
server {
	listen 80;
	server_name <%= @domains.join(' '); %>;

	return 301 https://$server_name$request_uri;
}
<% end %>

server {
	server_name <%= @domains.join(' '); %>;

	<% if not @vhost[:ssl].to_s.empty? %>
	listen 443 ssl;

	ssl on;
	ssl_certificate <%= node[:nginx][:dir] %>/ssl/<%= @vhost_name %>.crt;
	ssl_certificate_key <%= node[:nginx][:dir] %>/ssl/<%= @vhost_name %>.key;
	<% else %>
	listen 80;
	<% end %>

	access_log <%= @log_dir %>/access-<%= @domains[0] %>.log;
	error_log <%= @log_dir %>/error-<%= @domains[0] %>.log;

	include /etc/nginx/global.d/*.conf;

	<% if @vhost.has_key? :fcgi_proxy %>
	location / {
		try_files $uri @fcgi;
	}
	
	location @fcgi {
		include fastcgi_params;
		fastcgi_split_path_info		^(/)(.*)$;
		fastcgi_param				PATH_INFO		$fastcgi_path_info;
		fastcgi_param				SCRIPT_FILENAME	$document_root$fastcgi_script_name;
		fastcgi_pass				<%= @vhost[:fcgi_proxy] %>;
	}
	<% else # default www with php as fallback %>
	index index.php index.html index.htm;

	<% @locations.sort.reverse.each do |location, path| %>
		<%
			if location == '/'
				try_location = location
				php_location = ''
				root_alias = 'root'
				args = '?$args'
			else
				try_location = location + '/'
				php_location = '^' + location + '/'
				root_alias = 'alias'
				args = ''
			end
		%>
	location <%= location %> {
		<%= root_alias %> <%= path %>;
		try_files $uri $uri/ <%= try_location %>index.php<%= args %>;
	}

	# handle php files
	location ~ <%= php_location %>(.+\.php)$ {
		root <%= path %>;
		try_files /$1 $uri $uri/ <%= try_location %>index.php;
		include fastcgi_params;
		fastcgi_split_path_info ^(.+\.php)(/.+)$;
		fastcgi_pass unix:/var/run/php5-fpm-<%= @username %>.sock;
		fastcgi_index index.php;
	}
	<% end %>

	#error_page 404 /404.html;

	<% end %>

	location ~ /\.ht {
		deny all;<commit_msg>gzip + expires header<commit_after>##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# http://wiki.nginx.org/Pitfalls
# http://wiki.nginx.org/QuickStart
# http://wiki.nginx.org/Configuration
#
# Generally, you will want to move this file somewhere, and start with a clean
# file but keep this around for reference. Or just disable in sites-enabled.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##

<% if not @vhost[:ssl].to_s.empty? %>
server {
	listen 80;
	server_name <%= @domains.join(' '); %>;

	return 301 https://$server_name$request_uri;
}
<% end %>

server {
	server_name <%= @domains.join(' '); %>;

	<% if not @vhost[:ssl].to_s.empty? %>
	listen 443 ssl;

	ssl on;
	ssl_certificate <%= node[:nginx][:dir] %>/ssl/<%= @vhost_name %>.crt;
	ssl_certificate_key <%= node[:nginx][:dir] %>/ssl/<%= @vhost_name %>.key;
	<% else %>
	listen 80;
	<% end %>

	access_log <%= @log_dir %>/access-<%= @domains[0] %>.log;
	error_log <%= @log_dir %>/error-<%= @domains[0] %>.log;
    
    # gzip
    gzip on;
    gzip_min_length  1100;
    gzip_buffers  4 32k;
    gzip_types    text/plain application/x-javascript text/xml text/css;
    gzip_vary on;

	include /etc/nginx/global.d/*.conf;

	<% if @vhost.has_key? :fcgi_proxy %>
	location / {
		try_files $uri @fcgi;
	}
	
	location @fcgi {
		include fastcgi_params;
		fastcgi_split_path_info		^(/)(.*)$;
		fastcgi_param				PATH_INFO		$fastcgi_path_info;
		fastcgi_param				SCRIPT_FILENAME	$document_root$fastcgi_script_name;
		fastcgi_pass				<%= @vhost[:fcgi_proxy] %>;
	}
	<% else # default www with php as fallback %>
	index index.php index.html index.htm;

	<% @locations.sort.reverse.each do |location, path| %>
		<%
			if location == '/'
				try_location = location
				php_location = ''
				root_alias = 'root'
				args = '?$args'
			else
				try_location = location + '/'
				php_location = '^' + location + '/'
				root_alias = 'alias'
				args = ''
			end
		%>
	location <%= location %> {
		<%= root_alias %> <%= path %>;
		try_files $uri $uri/ <%= try_location %>index.php<%= args %>;

        # expires header
            location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
            expires 30d;
            add_header Pragma public;
            add_header Cache-Control "public";
        }
	}

	# handle php files
	location ~ <%= php_location %>(.+\.php)$ {
		root <%= path %>;
		try_files /$1 $uri $uri/ <%= try_location %>index.php;
		include fastcgi_params;
		fastcgi_split_path_info ^(.+\.php)(/.+)$;
		fastcgi_pass unix:/var/run/php5-fpm-<%= @username %>.sock;
		fastcgi_index index.php;
	}
	<% end %>

	#error_page 404 /404.html;

	<% end %>

	location ~ /\.ht {
		deny all;
{'fraction_non_alphanumeric': 0.17292069632495163, 'fraction_numerical': 0.009477756286266924, 'mean_word_length': 3.3344509639564124, 'pattern_counts': {'":': 0, '<': 65, '<?xml version=': 0, '>': 65, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 1}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '416395', 'n_tokens_mistral': 2237, 'n_tokens_neox': 1881, 'n_words': 446}