# Configures nginx locations for user specific directories, where the # username is a subdomain. class profiles::nginx_userdir ( $servername = $::fqdn, ) { include ::nginx # TODO wildcard certificate $_servername = regsubst($servername, '[.]', '\.', 'G', 'N') nginx::resource::server { "userdir ${servername}": server_name => ["~^(?P[a-z][-a-z0-9]*)\\.${_servername}"], use_default_location => false, www_root => '/home/$uname/.public', ssl => false, # * => letsencrypt::conf::nginx($servername), index_files => [ 'index.cgi', 'index.php', 'index.html', 'index.htm', ], } $nginx_defaults = { server => "userdir ${servername}", ssl => false, ssl_only => false, index_files => [], } nginx::resource::location { "userdir.${servername} /": location => '/', autoindex => 'on', try_files => [ '$uri', '$uri/', '=404', ], * => $nginx_defaults, } include ::profiles::fcgiwrap nginx::resource::location { "userdir.${servername} cgi": location => '~ \.cgi$', fastcgi => 'unix:/run/fcgiwrap.socket', # TODO isn't socket name os dependant fastcgi_param => { 'PATH_INFO' => '$fastcgi_script_name', 'QUERY_STRING' => '$args', }, * => $nginx_defaults, } include ::profiles::phpfpm # TODO doesn't socket location depend on both os and php version nginx::resource::location { "userdir.${servername} php": location => '~ \.php$', fastcgi => 'unix:/run/php/php-fpm.sock', fastcgi_params => "${nginx::conf_dir}/snippets/fastcgi-php.conf", * => $nginx_defaults, } nginx::resource::location { "userdir.${servername} deny .ht": location => '~ /\.ht', location_deny => ['all'], * => $nginx_defaults, } }