server_name <%= app[:server_names].join(' ') %>;
<% if app[:ssl] %>
    <% if app[:ssl_port] %>
        listen <%= nginx_listen_address(app) %>;
        listen <%= nginx_listen_address_with_ssl_port(app) %> ssl http2;
    <% else %>
        listen <%= nginx_listen_address(app) %> ssl http2;
    <% end %>
    ssl_certificate <%= app[:ssl_certificate] %>;
    ssl_certificate_key <%= app[:ssl_certificate_key] %>;
<% else %>
    listen <%= nginx_listen_address(app) %>;
<% end %>
<% if app[:static_files_dir] %>
    root '<%= app[:static_files_dir] %>';
<% else %>
    root '<%= app[:root] %>/public';
<% end %>

passenger_app_root '<%= app[:root] %>';
passenger_enabled on;

<% if app[:union_station_key] %>
    union_station_support on;
    union_station_key <%= app[:union_station_key] %>;
<% end %>
<% app[:envvars].each_pair do |name, value| %>
    passenger_env_var '<%= name %>' '<%= json_config_value(value) %>';
<% end %>
<% if app[:concurrency_model] && app[:concurrency_model] != DEFAULT_CONCURRENCY_MODEL %>
    passenger_concurrency_model <%= app[:concurrency_model] %>;
<% end %>
<% if app[:thread_count] && app[:thread_count] != DEFAULT_APP_THREAD_COUNT %>
    passenger_thread_count <%= app[:thread_count] %>;
<% end %>

<%= nginx_option(app, :environment, :passenger_app_env) %>
<%= nginx_option(app, :ruby) %>
<%= nginx_option(app, :python) %>
<%= nginx_option(app, :nodejs) %>
<%= nginx_option(app, :spawn_method) %>
<%= nginx_option(app, :app_type) %>
<%= nginx_option(app, :startup_file) %>
<%= nginx_option(app, :start_timeout) %>
<%= nginx_option(app, :min_instances) %>
<%= nginx_option(app, :max_request_queue_size) %>
<%= nginx_option(app, :restart_dir) %>
<%= nginx_option(app, :sticky_sessions) %>
<%= nginx_option(app, :sticky_sessions_cookie_name) %>
<%= nginx_option(app, :vary_turbocache_by_cookie) %>
<%= nginx_option(app, :meteor_app_settings) %>
<%= nginx_option(app, :load_shell_envvars) %>
<%= nginx_option(app, :app_file_descriptor_ulimit) %>
<%= nginx_option(app, :friendly_error_pages) %>
<%= nginx_option(app, :abort_websockets_on_process_shutdown) %>
<%= nginx_option(app, :force_max_concurrent_requests_per_process) %>
<%= nginx_option(app, :max_requests) %>

<%= nginx_option(app, :rolling_restarts) %>
<%= nginx_option(app, :resist_deployment_errors) %>
<%= nginx_option(app, :memory_limit) %>
<%= nginx_option(app, :max_request_time) %>
<%= nginx_option(app, :debugger) %>

<% app[:unlimited_concurrency_paths].each do |path| %>
    location ~ ^<%= path %>(/.*|$) {
        passenger_app_group_name '<%= app[:root] %>#unlimited_concurrency';
        passenger_force_max_concurrent_requests_per_process 0;
    }
<% end %>
